allow uncommon words for first guess
This commit is contained in:
parent
0436347f7d
commit
b18c03234a
2 changed files with 10678 additions and 11 deletions
|
@ -5,7 +5,7 @@ import * as wasm from 'web-optimle';
|
||||||
import { clue, describeClue, type Clue, type GuessResult } from './clue';
|
import { clue, describeClue, type Clue, type GuessResult } from './clue';
|
||||||
import { gameName, speak } from './util';
|
import { gameName, speak } from './util';
|
||||||
|
|
||||||
import { DICTIONARY } from './dictionary';
|
import { COMMON_WORDS, UNCOMMON_WORDS } from './dictionary';
|
||||||
import * as PUZZLES from './puzzles.json';
|
import * as PUZZLES from './puzzles.json';
|
||||||
import { Row, RowState } from './Row';
|
import { Row, RowState } from './Row';
|
||||||
import { Keyboard } from './Keyboard';
|
import { Keyboard } from './Keyboard';
|
||||||
|
@ -41,14 +41,11 @@ export function Game(props: GameProps) {
|
||||||
const [tryNumber, setTryNumber] = useState(1);
|
const [tryNumber, setTryNumber] = useState(1);
|
||||||
const [hint, setHint] = useState<JSX.Element | string>(
|
const [hint, setHint] = useState<JSX.Element | string>(
|
||||||
<p>
|
<p>
|
||||||
Try to guarantee a win in <strong>2 guesses,</strong> no matter the word!
|
Try to guarantee a win in <strong>2 guesses</strong>!
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
Today's puzzle (#{puzzle.seed}) has {puzzle.solutions} solution{puzzle.solutions === 1 ? '' : 's'}.
|
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
const tableRef = useRef<HTMLTableElement>(null);
|
const tableRef = useRef<HTMLTableElement>(null);
|
||||||
const game = useMemo(() => wasm.Game.new(DICTIONARY, puzzle.history), []);
|
const game = useMemo(() => wasm.Game.new(COMMON_WORDS, puzzle.history), []);
|
||||||
const reset = useCallback(() => {
|
const reset = useCallback(() => {
|
||||||
game.reset();
|
game.reset();
|
||||||
setGuesses([...puzzle.history]);
|
setGuesses([...puzzle.history]);
|
||||||
|
@ -103,9 +100,16 @@ export function Game(props: GameProps) {
|
||||||
setHint("Too short");
|
setHint("Too short");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!DICTIONARY.includes(currentGuess)) {
|
if (!COMMON_WORDS.includes(currentGuess)) {
|
||||||
setHint("Not a valid word");
|
if (!UNCOMMON_WORDS.includes(currentGuess)) {
|
||||||
return;
|
setHint("Not a valid word");
|
||||||
|
return;
|
||||||
|
} else if (guesses.length === puzzle.history.length) {
|
||||||
|
setHint("(Uncommon word allowed for first guess)");
|
||||||
|
} else {
|
||||||
|
setHint("(Uncommon word not allowed for second guess)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (const g of guesses) {
|
for (const g of guesses) {
|
||||||
const c = clue(g);
|
const c = clue(g);
|
||||||
|
@ -223,6 +227,9 @@ export function Game(props: GameProps) {
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
Today's puzzle (#{puzzle.seed}) has {puzzle.solutions} path{puzzle.solutions === 1 ? '' : 's'} to a win.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue