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

Moves, goals and assistance

Keep stable cell indices and immutable state through moves, undo and restart.

Work with native indices

import { classicTriangle,legalJumps,jumpAt,pegCount,undo,markHelped,restart } from "@johnmorrisdotca/tobiishi";
const start=classicTriangle().game;
const move=legalJumps(start)[0];
const next=markHelped(jumpAt(start,move.from,move.to));
console.log(pegCount(start),pegCount(next),undo(next).helped,restart(next).helped);
14 13 true false

A Jump uses from, over and to indices into its board’s stable cells. Drawing coordinates are derived separately. Invalid jumps return the same game; an undo with no history also returns it unchanged. A target of null permits any final hole. A non-null target requires the last peg at that exact native index.

Preserve the assistance flag

markHelped records a proved hint without changing pieces. Undo retains this marker; restart clears history and assistance while restoring the original peg arrangement. isGameStuck means no legal continuation remains before the goal is reached. It does not prove that an earlier position was unsolvable.

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