Reference · Rules, tiles and records
tradeChoicefunction
The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. Null for a hand of wilds.
Import it
import { tradeChoice } from "@johnmorrisdotca/kumimoji";
Definition
function tradeChoice(hand: readonly string[], words: TileWords): number | null
Parameters
| Name | Type | Description |
|---|---|---|
hand | readonly string[] | The hand size or tile codes, as declared by the function signature. |
words | TileWords | The loaded native language word list and tile mappings. |
Returns
number | null
The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. null for a hand of wilds.
Examples
import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
import { deal, tradeChoice } from "@johnmorrisdotca/kumimoji";
const words = await loadTileWordsFromModule("english");
const play = deal("catdog",3);
console.log(tradeChoice(play.hand,words));0What it prints (run when this page was built)