Reference · Rules, tiles and records
diagonalsReadfunction
Whether every diagonal run a laying's new tiles would stand in is taken by
isWord: each walked from its top end down, with the word's own letters on
its new squares. Only a run through a new tile can change, and two new
tiles of one word never share a diagonal (they share a row or a column), so
each is read on its own. A run of two, a corner touch, is never read.
Import it
import { diagonalsRead } from "@johnmorrisdotca/kumimoji";
Definition
function diagonalsRead(letterAt: (row: number, col: number) => string, inside: (row: number, col: number) => boolean, word: string, fit: CrossingFit, isWord: (run: string) => boolean): boolean
Parameters
| Name | Type | Description |
|---|---|---|
letterAt | (row: number, col: number) => string | The tile at a coordinate, or an empty string for no tile. |
inside | (row: number, col: number) => boolean | Whether a coordinate is within the caller’s working grid. |
word | string | The encoded word to lay or spell. |
fit | CrossingFit | The first coordinate and fresh tile coordinates of the proposed laying. |
isWord | (run: string) => boolean | The predicate that accepts a readable word. |
Returns
boolean
Whether every diagonal run a laying's new tiles would stand in is taken by isWord: each walked from its top end down, with the word's own letters on its new squares. Only a run through a new tile can change, and two new tiles of one word never share a diagonal (they share a row or a column), so each is read on its own. A run of two, a corner touch, is never read.
Examples
import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
import { diagonalsRead } from "@johnmorrisdotca/kumimoji";
const words = await loadTileWordsFromModule("english");
console.log(diagonalsRead(()=>"",()=>true,"cat",{first:{row:0,col:0},fresh:[{row:0,col:0},{row:0,col:1},{row:0,col:2}]},word=>words.allowed.has(word)));trueWhat it prints (run when this page was built)