Skip to the content

Tobiishi飛び石

Jump pegs on nine native boards, generate seeded solvable challenges and build a peg-solitaire player for your page.

Tobiishi is the Japanese word 飛び石 for stepping stones. About the name

Contents

How-to

Generate and verify seeded challenges

Use reverse-growth witnesses and inspect the actual returned length.

Replay the supplied witness

import { challengeOf,jumpAt,isGameSolved } from "@johnmorrisdotca/tobiishi";
const challenge=challengeOf("triangle","lesson-1",3);
let game=challenge.game;
for(const jump of challenge.answer) game=jumpAt(game,jump.from,jump.to);
console.log(challenge.answer.length,isGameSolved(game),challenge.seed);
3 true lesson-1

The generator grows backwards from one peg and returns the reverse jumps as a complete legal witness. Fix board shape, seed, requested length, optional goal and package version to recreate a lesson. The generated game owns its board and peg arrays.

Inspect requested and actual length

The general generator tries to grow to the requested length and can return its best shorter nonempty challenge. Check answer.length. Invalid length/goal inputs or a board with no challenge throw. Named goal packs additionally require their exact requested witness length, as described in named packs. Large generation examples should remain bounded or typechecked without running.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tobiishi 0.3.1.