Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rapid-draughts

loks0n68MIT1.0.6TypeScript support: included

A super speedy, blazing fast, rocket-powered TypeScript draughts/checkers engine with move validation, AI and game history.

draughts, draughts engine, draughts validation, checkers, checkers engine, draughts validation, boardgame, bitboard, english draughts

readme

rapid-draughts ⚡

npm version Downloads Known Vulnerabilities Package quality License

A super speedy, blazing fast, rocket-powered TypeScript draughts/checkers engine with move validation, AI and game history.

It uses bitboards, a board representation that holds the draughts board in three 32 or 64 bit unsigned integers. One for the light pieces, dark pieces and the king pieces. Bitboards enable fast move generation and have minimal memory usage.

The english draughts / american checkers engine follows the WCDF ruleset.

Installing

Run the following command inside your node project:

npm install rapid-draughts

How To Use

import { DraughtsPlayer, DraughtsStatus } from 'rapid-draughts';
import {
  EnglishDraughts as Draughts,
  EnglishDraughtsComputerFactory as ComputerFactory,
} from 'rapid-draughts/english';

// Initialise the game
const draughts = Draughts.setup();

// Show the available moves and play one.
console.table(draughts.moves);
draughts.move(draughts.moves[0]);

// Initialise two computer players
const weakComputer = ComputerFactory.random();
const strongComputer = ComputerFactory.alphaBeta({
  maxDepth: 7,
});

// Play with the AIs until there is a winner
while (draughts.status === DraughtsStatus.PLAYING) {
  console.log(`${draughts.asciiBoard()}`);
  console.log(`to_move = ${draughts.player}`);

  const computerPlayer =
    draughts.player === DraughtsPlayer.LIGHT ? weakComputer : strongComputer;

  const move = await computerPlayer(draughts);
  if (move) draughts.move(move);
}

// Announce the winner
console.log(`${draughts.asciiBoard()}`);
console.log(`status = ${draughts.status}`);
console.log(`ended after ${draughts.history.moves.length} moves`);

Online Demo

rapid-draughts powers the draughts game site draughts.org. Check it out!

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

1.0.5

1.0.4

25 December 2024

  • chore: bump packages, node version e7cd892
  • chore: remove stores 8ed7c3b
  • chore: remove international 0069e90

1.0.3

5 December 2024

1.0.2

28 April 2023

1.0.1

7 April 2023

1.0.0

5 April 2023

0.9.7

2 April 2023

0.9.6

1 April 2023

0.9.5

1 April 2023

0.9.4

1 April 2023

0.9.3

1 April 2023

0.9.2

30 March 2023

  • feat: rename S to EnglishDraughtsBitSquare d5d713f
  • feat: rename board1d string to asciiBoard d71ee90
  • test: add tests for utils c99afc2

0.9.1

30 March 2023

  • chore: bump packages cecb04c
  • feat: add isValidMove function to engine and game e032daf
  • feat: optimise bitwise utils c0c2df4

0.9.0

29 March 2023

  • Release 0.9.0 153298a
  • chore: refactor mask as default export 9246788
  • feat: reduce function calls in eval 90994e2

0.8.9

26 March 2023

0.8.8

26 March 2023

0.8.7

26 March 2023

0.8.6

26 March 2023

  • chore: add readonly to types 28908f1
  • feat: improve error messages in adapter fb98d67
  • Release 0.8.6 683806e

0.8.5

20 March 2023

0.8.4

20 March 2023

0.8.3

20 March 2023

0.8.2

20 March 2023

  • chore: update typings + entry point c695175
  • chore: update packages c5fa205
  • docs: update example imports d920a7a

0.8.1

16 March 2023

0.8.0

14 March 2023

0.7.1

10 March 2023

  • revert: remove 1d setup in favour of s array 0081daa
  • Release 0.7.1 0459c88
  • fix: remove unused imports 8652f4d

0.7.0

10 March 2023

0.6.1

9 March 2023

  • fix: rename factory methods to use setup over new 51b4dde
  • Release 0.6.1 2afbd05

0.6.0

9 March 2023

0.5.6

6 March 2023

0.5.5

6 March 2023

0.5.4

6 March 2023

0.5.3

3 March 2023

0.5.2

3 March 2023

0.5.1

3 March 2023

0.5.0

3 March 2023

0.4.1

17 February 2023

0.3.2

5 February 2023

0.3.1

3 February 2023

0.3.0

3 February 2023

0.2.0

25 January 2023

0.1.0

25 January 2023