ymir-js
v0.14.0 on npm

Board games,
as plain TypeScript.

Checkers, chess, Go and match-3 with their full rules, on a small Board and Item core you can build your own games on. No framework, no dependencies.

npm install @ymir-js/core

The board for your own games. Add a ready-made game with its own package: @ymir-js/chess, @ymir-js/checkers, @ymir-js/go or @ymir-js/match3.

Tutorials

Learn the core in 11 puzzles

A small board and a goal each: place an item, walk a robot around the walls, swap two pieces, undo a mess. Change a line or two, press Run and watch it play out.

Start the puzzles →

Games

Every one runs on the same Board and Item. Play them, then read the source.

In the library full rules, tested, ready to use

Built on @ymir-js/core example apps that write their own rules on the core; read their source

Hnefatafl: the king escapes to a corner

Hnefatafl

Viking chess: get the king to a corner.

Reversi: discs flipping

Reversi

Flips along eight lines from one core call.

Sokoban: a level solved

Sokoban

Push boxes; undo and a solver.

Tactics: units move and attack

Tactics

Turn-based battle with ranges and paths.

Bomberman: bombs and crates

Bomberman

Real time: bombs, chains, power-ups.

Invaders: a wave shot down

Invaders

Real time: a marching formation, shields.

Packages

Install only what you use. Every game package builds on @ymir-js/core; all of them are at v0.14.0 and released together.

@ymir-js/core

Your own games

The board everything is built on: squares and items, movement patterns, directions, rays, reach and paths, snapshots.

npm install @ymir-js/core

@ymir-js/checkers

CheckersGame

Turkish and International checkers: full rules, capture chains, draws, undo and PDN notation.

npm install @ymir-js/checkers

@ymir-js/chess

ChessGame

Every rule, FEN / SAN / UCI / PGN, perft-verified move generation and a small engine.

npm install @ymir-js/chess

@ymir-js/go

GoGame

Captures, ko and superko, pass and resign, dead stones, area and territory scoring.

npm install @ymir-js/go

@ymir-js/match3

Match3Board

Swaps, matches, gravity, refills and cascades reported step by step.

npm install @ymir-js/match3

Using it

Plain classes: read the state, call a method, draw it however you like.

import { ChessGame } from '@ymir-js/chess';
import { GoGame } from '@ymir-js/go';
import { CheckersGame } from '@ymir-js/checkers';

const chess = new ChessGame();
chess.move('e4');
chess.getBestMove({ depth: 3 }); // { san: 'Nf6', ... }

const go = new GoGame({ size: 9 });
go.play('4|4');
go.getStatus(); // { state: 'playing' }

const checkers = CheckersGame.create('turkish');
checkers.getLegalMoves(); // [{ from, path, captured }, ...]
  • Rules you can trustTested against the official rules: perft for chess, FMJD and Turkish federation rules for checkers.
  • Any UINo rendering, no framework. The examples use Preact; use what you like.
  • Typed, zero dependenciesTypeScript, an ES module with types, nothing else installed.
  • Your own gamesThe tutorials cover the whole core. The custom games show where it goes.