Reference · Tiles, layouts and deals
playSolvefunction
PLAY THE MOVES ON THE DEAL, refusing the first that the rules do not allow: a pair that is not two free tiles that match, or a shuffle while a pair could still be taken (Shuffle is for when you are stuck), or one that cannot help. Null for a deal or a move that does not read.
Import it
import { playSolve } from "@johnmorrisdotca/jarajara";
Definition
function playSolve(size: number, givens: string, moves: readonly MahjongMove[], rule?: MahjongBonusRule): Replayed | null
Parameters
| Name | Type | Description |
|---|---|---|
size | number | The native layout size identifier, measured in tiles across. |
givens | string | The original face-code deal in native slot order. |
moves | readonly MahjongMove[] | The native pair and shuffle moves in chronological order. |
rule (optional) | MahjongBonusRule | Grouped or identical bonus matching. |
Returns
Replayed | null
PLAY THE MOVES ON THE DEAL, refusing the first that the rules do not allow: a pair that is not two free tiles that match, or a shuffle while a pair could still be taken (Shuffle is for when you are stuck), or one that cannot help. null for a deal or a move that does not read.
Examples
import { generateAwase } from "@johnmorrisdotca/jarajara/awase";
import { freePairs, geometryOf, layoutFor, playSolve } from "@johnmorrisdotca/jarajara";
const deal = generateAwase(4,"easy",2026);
const layout = layoutFor(4)!;
const geometry = geometryOf(layout);
const cells = deal.givens;
const pair = freePairs(geometry,cells,"group")[0];
console.log(playSolve(4,cells,[{pair}],"group")?.cells);xPNx.BB.What it prints (run when this page was built)