# muhammadzain-nu/chess-with-ai-bot architecture

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

- Interactive diagram: https://gitdiagram.com/muhammadzain-nu/chess-with-ai-bot
- Repository: https://github.com/muhammadzain-nu/chess-with-ai-bot

## Overview

This is a graphical chess game with a computer-opponent option. A player interacts with the FreeGLUT interface, which manages game input and display; moves are checked and applied by the chess rules engine. The computer player searches for moves, and an opening-book capability is also present. The excerpts show the AI and opening-book modules using the board rules, but do not show the UI’s dispatch to either module, so those UI links are marked unverified.

Main entry points: [`main.cpp`](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/main.cpp) (Game UI), [`chessboard.cpp`](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/chessboard.cpp) (Board and rules), [`AI.cpp`](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/AI.cpp) (AI search), [`OpeningBook.cpp`](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/OpeningBook.cpp) (Opening book)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Game interface"]
  node_ui["Game UI<br/>[main.cpp]"]
end

subgraph group_rules["Chess rules"]
  node_board["Board and rules<br/>[chessboard.cpp]"]
  node_bitops["Bit operations<br/>[bitops.h]"]
end

subgraph group_computer["Computer play"]
  node_ai["AI search<br/>[AI.cpp]"]
  node_book["Opening book<br/>[OpeningBook.cpp]"]
end

node_player(("Player"))

node_player -->|"plays through"| node_ui
node_ui -->|"checks and updates"| node_board
node_board -->|"uses bit scans"| node_bitops
node_ai -->|"searches positions"| node_board
node_book -->|"validates moves"| node_board
node_ui -.->|"requests move"| node_ai
node_ui -.->|"checks openings"| node_book

click node_ui "https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/main.cpp"
click node_board "https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/chessboard.cpp"
click node_bitops "https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/bitops.h"
click node_ai "https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/AI.cpp"
click node_book "https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/OpeningBook.cpp"

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_ui toneBlue
class node_board,node_bitops toneAmber
class node_ai,node_book toneMint
class node_player toneIndigo
```

## Components

### Game interface

- [Game UI](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/main.cpp): `main.cpp`

### Chess rules

- [Board and rules](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/chessboard.cpp): `chessboard.cpp`
- [Bit operations](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/bitops.h): `bitops.h`

### Computer play

- [AI search](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/AI.cpp): `AI.cpp`
- [Opening book](https://github.com/muhammadzain-nu/chess-with-ai-bot/blob/main/OpeningBook.cpp): `OpeningBook.cpp`

### Other components

- **Player**

## Connections

- Player → Game UI: plays through (evidence: `main.cpp`)
- Game UI → Board and rules: checks and updates (evidence: `main.cpp`)
- Board and rules → Bit operations: uses bit scans (evidence: `chessboard.cpp`)
- AI search → Board and rules: searches positions (evidence: `AI.cpp`)
- Opening book → Board and rules: validates moves (evidence: `OpeningBook.cpp`)
- Game UI → AI search: requests move
- Game UI → Opening book: checks openings
