# rapid-draughts

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

Latest version **1.0.6** (published 2025-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install rapid-draughts
pnpm add rapid-draughts
yarn add rapid-draughts
bun add rapid-draughts
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2025-02-05 |
| First published | 2023-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 166.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | loks0n |
| Maintainers | loks0n |
| Keywords | draughts, draughts engine, draughts validation, checkers, checkers engine, draughts validation, boardgame, bitboard, english draughts |

## Links

- npm: https://www.npmjs.com/package/rapid-draughts
- Repository: https://github.com/loks0n/rapid-draughts
- Homepage: https://loks0n.dev/projects/rapid-draughts
- Issues: https://github.com/loks0n/rapid-draughts/issues
- npm.io page: https://npm.io/package/rapid-draughts

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2025-02-05
- 1.0.5 — 2024-12-28
- 1.0.4 — 2024-12-25
- 1.0.3 — 2024-12-05
- 1.0.2 — 2023-04-28
- 1.0.1 — 2023-04-07
- 1.0.0 — 2023-04-05
- 0.9.7 — 2023-04-02
- 0.9.6 — 2023-04-01
- 0.9.5 — 2023-04-01
- 0.9.4 — 2023-04-01
- 0.9.3 — 2023-04-01
- 0.9.2 — 2023-03-30
- 0.9.1 — 2023-03-30
- 0.9.0 — 2023-03-29
- … 29 more at https://npm.io/package/rapid-draughts/versions

## README

# rapid-draughts ⚡

[![npm version](https://badge.fury.io/js/rapid-draughts.svg)](https://badge.fury.io/js/rapid-draughts)
![Downloads](https://img.shields.io/npm/dt/rapid-draughts)
![Known Vulnerabilities](https://snyk.io/test/github/loks0n/rapid-draughts/badge.svg)
[![Package quality](https://packagequality.com/shield/rapid-draughts.png)](https://packagequality.com/#?package=rapid-draughts)
![License](https://img.shields.io/github/license/loks0n/rapid-draughts?color=lightgrey)

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](https://www.wcdf.net/rules.htm).

## Installing

Run the following command inside your node project:
```bash
npm install rapid-draughts
```

## How To Use

```typescript
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](https://draughts.org/). Check it out!

---
_Source: https://npm.io/package/rapid-draughts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
