Reference · Rules, tiles and records
bestLayingfunction
THE COMPUTER'S NEXT WORD: its play after laying the best word its hand can
lay on its table, and the word, or null when there is none. The grid after
it is judged against the list, by the game's rules (rules), and is
always sound.
Import it
import { bestLaying } from "@johnmorrisdotca/kumimoji";
Definition
function bestLaying(play: TilePlay, words: TileWords, rules?: GridRules): { play: TilePlay; word: string; } | null
Parameters
| Name | Type | Description |
|---|---|---|
play | TilePlay | The current immutable solo-game progress. |
words | TileWords | The loaded native language word list and tile mappings. |
rules (optional) | GridRules | Whether diagonal runs are also judged. |
Returns
{ play: TilePlay; word: string; } | null
THE COMPUTER'S NEXT WORD: its play after laying the best word its hand can lay on its table, and the word, or null when there is none. The grid after it is judged against the list, by the game's rules (rules), and is always sound.
Examples
import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
import { bestLaying, deal } from "@johnmorrisdotca/kumimoji";
const words = await loadTileWordsFromModule("english");
const play = deal("catdog",3);
console.log(bestLaying(play,words)?.word);actWhat it prints (run when this page was built)