Compare commits
No commits in common. "ada1f6884ddeda71bad0221845b47355917dae89" and "6a1496df74c1be34941a3532d278afe8d3825fca" have entirely different histories.
ada1f6884d
...
6a1496df74
|
@ -138,24 +138,6 @@ class CrosswordPuzzle {
|
||||||
clue.horizontal));
|
clue.horizontal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get width() {
|
|
||||||
let colOffset = -Math.min(...this.clues.map(clue => clue.col));
|
|
||||||
|
|
||||||
let numCols = colOffset+Math.max(...this.clues.map(clue => clue.afterCol));
|
|
||||||
return numCols;
|
|
||||||
}
|
|
||||||
|
|
||||||
get height() {
|
|
||||||
let rowOffset = -Math.min(...this.clues.map(clue => clue.row));
|
|
||||||
|
|
||||||
let numRows = rowOffset+Math.max(...this.clues.map(clue => clue.afterRow));
|
|
||||||
return numRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
get largestDimension() {
|
|
||||||
return Math.max(this.width, this.height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
class Crossword {
|
class Crossword {
|
||||||
constructor(letters, clues, minGuessLength, allTopWords) {
|
constructor(letters, clues, minGuessLength, allTopWords) {
|
||||||
|
@ -328,22 +310,6 @@ class Crossword {
|
||||||
return {'maxIntersections': maxIntersections,
|
return {'maxIntersections': maxIntersections,
|
||||||
'options': possibleCluesForWord};
|
'options': possibleCluesForWord};
|
||||||
}
|
}
|
||||||
function selectRandomCrossword(crosswords) {
|
|
||||||
let best = [];
|
|
||||||
let smallestSize = null;
|
|
||||||
|
|
||||||
crosswords.forEach(crossword => {
|
|
||||||
let size = crossword.largestDimension;
|
|
||||||
if (smallestSize == null || size < smallestSize) {
|
|
||||||
best = [crossword];
|
|
||||||
smallestSize = size;
|
|
||||||
} else if(size == smallestSize) {
|
|
||||||
best.push(crossword);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return best[getRandomInt(best.length)];
|
|
||||||
}
|
|
||||||
function tryAugmentCrosswords(crosswords) {
|
function tryAugmentCrosswords(crosswords) {
|
||||||
let defaultResult = null;
|
let defaultResult = null;
|
||||||
for (let topWordsIdx in matchingTopWords) {
|
for (let topWordsIdx in matchingTopWords) {
|
||||||
|
@ -367,7 +333,8 @@ class Crossword {
|
||||||
}).filter(possibleClue => possibleClue.newClue.intersections
|
}).filter(possibleClue => possibleClue.newClue.intersections
|
||||||
== maxIntersections));
|
== maxIntersections));
|
||||||
// TODO Other considerations for selecting best crossword?
|
// TODO Other considerations for selecting best crossword?
|
||||||
return selectRandomCrossword(possibleClues.map(selectedClue => selectedClue.baseCrossword.withClue(selectedClue.newClue)));
|
let selectedClue = possibleClues[getRandomInt(possibleClues.length)];
|
||||||
|
return selectedClue.baseCrossword.withClue(selectedClue.newClue);
|
||||||
} else if (defaultResult === null && possibleClues.some(crosswordOptions => crosswordOptions.possibleClues.options.length > 0)) {
|
} else if (defaultResult === null && possibleClues.some(crosswordOptions => crosswordOptions.possibleClues.options.length > 0)) {
|
||||||
defaultResult = possibleClues;
|
defaultResult = possibleClues;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +358,7 @@ class Crossword {
|
||||||
.withClue(newClue)));
|
.withClue(newClue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectRandomCrossword(crosswords);
|
return crosswords[getRandomInt(crosswords.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
let crossword = new CrosswordPuzzle()
|
let crossword = new CrosswordPuzzle()
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
#crossword td {
|
#crossword td {
|
||||||
width: 4ex;
|
width: 5vw;
|
||||||
height: 4ex;
|
height: 5vw;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 4ex;
|
font-size: 5vw;
|
||||||
}
|
}
|
||||||
#crossword td.blank {
|
#crossword td.blank {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user