Getting started
Getting started
Install Hitotsu, deal from a seed and play one legal move.
Install Hitotsu, deal a deterministic hand and apply one legal move. The rules engine works in Node 22 or later and in a browser, with no runtime dependency.
Install
npm install @johnmorrisdotca/hitotsuThe package ships its own types. React is optional and used only by the React entry.
Deal and play
import { HITOTSU_CLASSIC, hitotsuMoves, playHitotsu, startHitotsu } from "@johnmorrisdotca/hitotsu";
const game = startHitotsu(1, ["Aki", "Ben"], 42, HITOTSU_CLASSIC);
if (game === null) throw new Error("Invalid setup");
console.log(game.hands.map((hand) => hand.length));
const move = hitotsuMoves(game)[0]!;
const next = playHitotsu(game, move);
console.log(game.moves.length, next?.moves.length);[ 7, 7 ]
0 1A game is plain data. A legal move produces a new game and leaves the input unchanged. Start by asking the engine for its legal moves, rather than guessing whether a card can be played.
Choose your integration
Mount or embed a table for local play, run a computer, save a game, or use the shared-table adapter. The main entry documents every engine export.