Getting started
Getting started
Install Toranpu, start a seeded game and play one legal move.
Install the package, start a seeded game and make one legal move. The engines are plain functions and work in Node 22 or later without a page.
Install
npm install @johnmorrisdotca/toranpuThe package has no runtime dependencies and includes its types. React is an optional peer for the separate hook entry.
Start and play
import { newGame, rulesFor } from "@johnmorrisdotca/toranpu";
const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 });
if (game === null) throw new Error("Unsupported setup");
const rules = rulesFor("hearts");
const next = rules.play(game, rules.moves(game)[0]!);
console.log(game.phase, game.moves.length);
console.log(next?.phase, next?.moves.length);passing 0
passing 1A move may be a pass, a bid or a discard before ordinary card play begins. Ask the native rules for the current choices. play returns a new game and leaves the input unchanged; null means the move was refused.
Pick an entry
The main entry offers eleven games by key, shared words and exports. Each game also has its own named entry and a root namespace such as hearts. The deck entry offers card objects for games of your own. Solitaires have separate entries.
Next steps
Run computers, save and export, display your cards, play a solitaire, or embed and use React.