Reference · Boards, rules and challenges
legalJumpsfunction
Lists legal jumps from the current position.
Import it
import { legalJumps } from "@johnmorrisdotca/tobiishi";
Definition
function legalJumps(game: Game): Jump[]
Parameters
| Name | Type | Description |
|---|---|---|
game | Readonly<{ board: Board; start: readonly boolean[]; pegs: readonly boolean[]; target: number | null; history: readonly Jump[]; helped: boolean; }> | The immutable native peg position, board, target, history and assistance marker. |
Returns
Readonly<{ from: number; over: number; to: number; }>[]
Lists legal jumps from the current position.
Examples
import { legalJumps, makeBoard, newGame } from "@johnmorrisdotca/tobiishi";
const board = makeBoard("Three holes",[{x:0,y:0},{x:1,y:0},{x:2,y:0}]);
const game = newGame(board,[true,true,false],2);
console.log(legalJumps(game));[ { from: 0, over: 1, to: 2 } ]What it prints (run when this page was built)