# loks0n/rapid-draughts architecture

> Architecture diagram of the GitHub repository loks0n/rapid-draughts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/loks0n/rapid-draughts
- Repository: https://github.com/loks0n/rapid-draughts

## Overview

rapid-draughts is a TypeScript draughts/checkers engine implementing English draughts under WCDF rules. The main workflow is to set up a game, expose legal moves and board state, accept a move, and update game history; callers can also request moves from random or alpha-beta computer opponents. Internally, the generic game and engine layers separate the 1D public representation from bitboard rules. The README also documents bitboard-based performance and AI; unsampled modules are included where their role is supported by the source index, but their internal call paths are not inferred.

Main entry points: [`src/core/engine.ts`](https://github.com/loks0n/rapid-draughts/blob/main/src/core/engine.ts) (Generic Engine), [`src/core/game.ts`](https://github.com/loks0n/rapid-draughts/blob/main/src/core/game.ts) (Game State and History), [`src/english/computer.ts`](https://github.com/loks0n/rapid-draughts/blob/main/src/english/computer.ts) (English Computer Factory), [`src/english/game.ts`](https://github.com/loks0n/rapid-draughts/blob/main/src/english/game.ts) (English Game API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public_game["Game Interface"]
  node_english_game["English Game API<br/>[game.ts]"]
  node_game_history["Game State and History<br/>[game.ts]"]
  node_board_formatting["Board Formatting<br/>[utils.ts]"]
end

subgraph group_rules["English Rules"]
  node_english_engine["English Rules Engine<br/>[engine.ts]"]
  node_move_generation["Move Generation<br/>[move-generation.ts]"]
  node_board_masks["Board Masks<br/>[mask.ts]"]
end

subgraph group_engine_core["Engine Core"]
  node_engine["Generic Engine<br/>[engine.ts]"]
end

subgraph group_computer_players["Computer Players"]
  node_computer_api["Computer Strategy API<br/>[computer.ts]"]
  node_english_computer["English Computer Factory<br/>[computer.ts]"]
  node_alpha_beta["Alpha-Beta Search<br/>[alpha-beta.ts]"]
  node_random_strategy["Random Strategy<br/>[random.ts]"]
end

subgraph group_bitboard_ops["Bitboard Operations"]
  node_number_bitwise["Number Bitboards<br/>[number.ts]"]
  node_long_bitwise["Long Bitboards<br/>[long.ts]"]
  node_bitboard_types["Bitboard Types<br/>[types.ts]"]
end

node_caller(("Library Caller"))

node_caller -->|"sets up"| node_english_game
node_caller -->|"plays moves"| node_game_history
node_english_game -->|"creates"| node_engine
node_english_game -->|"constructs"| node_game_history
node_game_history -->|"delegates moves"| node_engine
node_game_history -->|"formats board"| node_board_formatting
node_engine -->|"uses strategy"| node_english_engine
node_english_engine -->|"requests moves"| node_move_generation
node_english_engine -->|"uses masks"| node_board_masks
node_move_generation -->|"uses masks"| node_board_masks
node_english_computer -->|"builds opponents"| node_computer_api
node_english_computer -->|"selects strategy"| node_alpha_beta
node_english_computer -->|"selects strategy"| node_random_strategy
node_computer_api -->|"passes engine"| node_engine
node_computer_api -->|"adapts move"| node_game_history
node_alpha_beta -->|"searches positions"| node_engine
node_random_strategy -->|"chooses legal move"| node_engine
node_number_bitwise -->|"implements operations"| node_bitboard_types
node_long_bitwise -->|"implements operations"| node_bitboard_types
node_english_computer -->|"offers AI moves"| node_caller

click node_english_game "https://github.com/loks0n/rapid-draughts/blob/main/src/english/game.ts"
click node_game_history "https://github.com/loks0n/rapid-draughts/blob/main/src/core/game.ts"
click node_board_formatting "https://github.com/loks0n/rapid-draughts/blob/main/src/core/utils.ts"
click node_english_engine "https://github.com/loks0n/rapid-draughts/blob/main/src/english/engine.ts"
click node_move_generation "https://github.com/loks0n/rapid-draughts/blob/main/src/english/move-generation.ts"
click node_board_masks "https://github.com/loks0n/rapid-draughts/blob/main/src/english/mask.ts"
click node_engine "https://github.com/loks0n/rapid-draughts/blob/main/src/core/engine.ts"
click node_computer_api "https://github.com/loks0n/rapid-draughts/blob/main/src/computer/computer.ts"
click node_english_computer "https://github.com/loks0n/rapid-draughts/blob/main/src/english/computer.ts"
click node_alpha_beta "https://github.com/loks0n/rapid-draughts/blob/main/src/computer/alpha-beta.ts"
click node_random_strategy "https://github.com/loks0n/rapid-draughts/blob/main/src/computer/random.ts"
click node_number_bitwise "https://github.com/loks0n/rapid-draughts/blob/main/src/bitwise/number.ts"
click node_long_bitwise "https://github.com/loks0n/rapid-draughts/blob/main/src/bitwise/long.ts"
click node_bitboard_types "https://github.com/loks0n/rapid-draughts/blob/main/src/bitwise/types.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_english_game,node_game_history,node_board_formatting toneBlue
class node_english_engine,node_move_generation,node_board_masks toneAmber
class node_engine toneMint
class node_computer_api,node_english_computer,node_alpha_beta,node_random_strategy toneRose
class node_number_bitwise,node_long_bitwise,node_bitboard_types,node_caller toneIndigo
```

## Components

### Game Interface

- [English Game API](https://github.com/loks0n/rapid-draughts/blob/main/src/english/game.ts): `src/english/game.ts`
- [Game State and History](https://github.com/loks0n/rapid-draughts/blob/main/src/core/game.ts): `src/core/game.ts`
- [Board Formatting](https://github.com/loks0n/rapid-draughts/blob/main/src/core/utils.ts): `src/core/utils.ts`

### English Rules

- [English Rules Engine](https://github.com/loks0n/rapid-draughts/blob/main/src/english/engine.ts): `src/english/engine.ts`
- [Move Generation](https://github.com/loks0n/rapid-draughts/blob/main/src/english/move-generation.ts): `src/english/move-generation.ts`
- [Board Masks](https://github.com/loks0n/rapid-draughts/blob/main/src/english/mask.ts): `src/english/mask.ts`

### Engine Core

- [Generic Engine](https://github.com/loks0n/rapid-draughts/blob/main/src/core/engine.ts): `src/core/engine.ts`

### Computer Players

- [Computer Strategy API](https://github.com/loks0n/rapid-draughts/blob/main/src/computer/computer.ts): `src/computer/computer.ts`
- [English Computer Factory](https://github.com/loks0n/rapid-draughts/blob/main/src/english/computer.ts): `src/english/computer.ts`
- [Alpha-Beta Search](https://github.com/loks0n/rapid-draughts/blob/main/src/computer/alpha-beta.ts): `src/computer/alpha-beta.ts`
- [Random Strategy](https://github.com/loks0n/rapid-draughts/blob/main/src/computer/random.ts): `src/computer/random.ts`

### Bitboard Operations

- [Number Bitboards](https://github.com/loks0n/rapid-draughts/blob/main/src/bitwise/number.ts): `src/bitwise/number.ts`
- [Long Bitboards](https://github.com/loks0n/rapid-draughts/blob/main/src/bitwise/long.ts): `src/bitwise/long.ts`
- [Bitboard Types](https://github.com/loks0n/rapid-draughts/blob/main/src/bitwise/types.ts): `src/bitwise/types.ts`

### Other components

- **Library Caller**

## Connections

- Library Caller → English Game API: sets up (evidence: `README.md`)
- Library Caller → Game State and History: plays moves (evidence: `README.md`)
- English Game API → Generic Engine: creates (evidence: `src/english/game.ts`)
- English Game API → Game State and History: constructs (evidence: `src/english/game.ts`)
- Game State and History → Generic Engine: delegates moves (evidence: `src/core/game.ts`)
- Game State and History → Board Formatting: formats board (evidence: `src/core/game.ts`)
- Generic Engine → English Rules Engine: uses strategy (evidence: `src/english/engine.ts`)
- English Rules Engine → Move Generation: requests moves (evidence: `src/english/engine.ts`)
- English Rules Engine → Board Masks: uses masks (evidence: `src/english/engine.ts`)
- Move Generation → Board Masks: uses masks (evidence: `src/english/move-generation.ts`)
- English Computer Factory → Computer Strategy API: builds opponents (evidence: `src/english/computer.ts`)
- English Computer Factory → Alpha-Beta Search: selects strategy (evidence: `src/english/computer.ts`)
- English Computer Factory → Random Strategy: selects strategy (evidence: `src/english/computer.ts`)
- Computer Strategy API → Generic Engine: passes engine (evidence: `src/computer/computer.ts`)
- Computer Strategy API → Game State and History: adapts move (evidence: `src/computer/computer.ts`)
- Alpha-Beta Search → Generic Engine: searches positions (evidence: `src/computer/alpha-beta.ts`)
- Random Strategy → Generic Engine: chooses legal move (evidence: `src/computer/random.ts`)
- Number Bitboards → Bitboard Types: implements operations (evidence: `src/bitwise/number.ts`)
- Long Bitboards → Bitboard Types: implements operations (evidence: `src/bitwise/long.ts`)
- English Computer Factory → Library Caller: offers AI moves (evidence: `README.md`)
