# nfleig/chessailibrary architecture

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

- Interactive diagram: https://gitdiagram.com/nfleig/chessailibrary
- Repository: https://github.com/nfleig/chessailibrary

## Overview

ChessAILibrary is a lightweight chess implementation with AI search and position evaluation. Its principal workflow is to represent a position, generate legal chess moves and resulting positions, search candidate positions, and score them. The rules, move notation, and board state are implemented together in SimpleChess.cs; AI search is split between MTD and AlphaBeta. The README is brief, and the graph reflects only the shown source and documented capabilities; it does not infer an external application or unsampled integrations.

Main entry points: [`ChessAILibrary/ChessAI/AlphaBeta.cs`](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/AlphaBeta.cs) (Alpha-Beta Search), [`ChessAILibrary/ChessAI/ChessAI.cs`](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/ChessAI.cs) (Chess AI Engine), [`ChessAILibrary/ChessAI/MTD.cs`](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/MTD.cs) (MTD Search), [`ChessAILibrary/ChessAI/SimpleChess.cs`](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/SimpleChess.cs) (Chess Position)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chess["Chess Rules"]
  node_board["Chess Position<br/>[SimpleChess.cs]"]
  node_moves["Move Generation<br/>[SimpleChess.cs]"]
  node_notation["Move Notation<br/>[SimpleChess.cs]"]
end

subgraph group_ai["AI Search"]
  node_evaluation["Position Evaluation<br/>[ChessAI.cs]"]
  node_engine["Chess AI Engine<br/>[ChessAI.cs]"]
  node_alphabeta["Alpha-Beta Search<br/>[AlphaBeta.cs]"]
  node_mtd["MTD Search<br/>[MTD.cs]"]
  node_searchstate["Search State<br/>[AIState.cs]"]
end

subgraph group_types["Chess Types"]
  node_types["Board and Move Types<br/>[ChessBoard.cs]"]
end

node_user(("Library User"))

node_user -.->|"uses"| node_engine
node_engine -->|"evaluates"| node_board
node_engine -->|"generates positions"| node_moves
node_alphabeta -->|"checks draws"| node_board
node_alphabeta -->|"generates positions"| node_moves
node_alphabeta -->|"scores leaves"| node_evaluation
node_alphabeta -->|"extends"| node_engine
node_mtd -->|"runs searches"| node_alphabeta
node_mtd -->|"updates"| node_searchstate

click node_board "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/SimpleChess.cs"
click node_moves "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/SimpleChess.cs"
click node_notation "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/SimpleChess.cs"
click node_evaluation "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/ChessAI.cs"
click node_engine "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/ChessAI.cs"
click node_alphabeta "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/AlphaBeta.cs"
click node_mtd "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/MTD.cs"
click node_searchstate "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/AIState.cs"
click node_types "https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/ChessBoard.cs"

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_board,node_moves,node_notation,node_user toneBlue
class node_evaluation,node_engine,node_alphabeta,node_mtd,node_searchstate toneAmber
class node_types toneMint
```

## Components

### Chess Rules

- [Chess Position](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/SimpleChess.cs): `ChessAILibrary/ChessAI/SimpleChess.cs`
- [Move Generation](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/SimpleChess.cs): `ChessAILibrary/ChessAI/SimpleChess.cs`
- [Move Notation](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/SimpleChess.cs): `ChessAILibrary/ChessAI/SimpleChess.cs`

### AI Search

- [Position Evaluation](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/ChessAI.cs): `ChessAILibrary/ChessAI/ChessAI.cs`
- [Chess AI Engine](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/ChessAI.cs): `ChessAILibrary/ChessAI/ChessAI.cs`
- [Alpha-Beta Search](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/AlphaBeta.cs): `ChessAILibrary/ChessAI/AlphaBeta.cs`
- [MTD Search](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/MTD.cs): `ChessAILibrary/ChessAI/MTD.cs`
- [Search State](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/AIState.cs): `ChessAILibrary/ChessAI/AIState.cs`

### Chess Types

- [Board and Move Types](https://github.com/nfleig/chessailibrary/blob/main/ChessAILibrary/ChessAI/ChessBoard.cs): `ChessAILibrary/ChessAI/ChessBoard.cs`

### Other components

- **Library User**

## Connections

- Library User → Chess AI Engine: uses
- Chess AI Engine → Chess Position: evaluates (evidence: `ChessAILibrary/ChessAI/ChessAI.cs`)
- Chess AI Engine → Move Generation: generates positions (evidence: `ChessAILibrary/ChessAI/ChessAI.cs`)
- Alpha-Beta Search → Chess Position: checks draws (evidence: `ChessAILibrary/ChessAI/AlphaBeta.cs`)
- Alpha-Beta Search → Move Generation: generates positions (evidence: `ChessAILibrary/ChessAI/AlphaBeta.cs`)
- Alpha-Beta Search → Position Evaluation: scores leaves (evidence: `ChessAILibrary/ChessAI/AlphaBeta.cs`)
- Alpha-Beta Search → Chess AI Engine: extends (evidence: `ChessAILibrary/ChessAI/AlphaBeta.cs`)
- MTD Search → Alpha-Beta Search: runs searches (evidence: `ChessAILibrary/ChessAI/MTD.cs`)
- MTD Search → Search State: updates (evidence: `ChessAILibrary/ChessAI/MTD.cs`)
