# ruskpr/chess architecture

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

- Interactive diagram: https://gitdiagram.com/ruskpr/chess
- Repository: https://github.com/ruskpr/chess

## Overview

This repository is a C# chess library with console and Windows Forms clients, plus UDP multiplayer support. The main workflow is to select a play mode, render and interact with a board, validate moves against piece movement rules, and—when networked—exchange packets with a server that manages game state. The graph also captures Chess960 setup and AI move selection. Relationships are limited to calls or references shown in the supplied excerpts, SOURCE INDEX, or README; some application details remain unsampled.

Main entry points: [`Chess.Core/Board.cs`](https://github.com/ruskpr/chess/blob/master/Chess.Core/Board.cs) (Board State), [`Applications/ChessClient/FormUDPClient.cs`](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormUDPClient.cs) (Network Client UI), [`Applications/ChessClient/FormLauncher.cs`](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormLauncher.cs) (Mode Launcher), [`Applications/ChessClient/FormAIvsAI.cs`](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormAIvsAI.cs) (AI Match)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Play Applications"]
  node_launcher["Mode Launcher<br/>[FormLauncher.cs]"]
  node_desktop["Desktop Play"]
  node_ai["AI Match<br/>[FormAIvsAI.cs]"]
  node_console["Console Play<br/>[Program.cs]"]
  node_uihelpers["Board UI Helpers<br/>[ChessUtils.cs]"]
end

subgraph group_rules["Chess Rules"]
  node_board["Board State<br/>[Board.cs]"]
  node_tile["Tiles<br/>[Tile.cs]"]
  node_location["Board Coordinates<br/>[BoardLocation.cs]"]
  node_game["Game and Turns<br/>[Game.cs]"]
  node_move["Move Model<br/>[Move.cs]"]
  node_piece["Piece Base<br/>[Piece.cs]"]
  node_pieceinterface["Piece Contract<br/>[IPiece.cs]"]
  node_movement["Move Validation<br/>[Movement.cs]"]
  node_pieces["Piece Rules<br/>[Pieces]"]
  node_chess960["Chess960 Setup"]
  node_aialgorithms["AI Algorithms<br/>[Algorithms]"]
end

subgraph group_network["UDP Multiplayer"]
  node_udpform["Network Client UI<br/>[FormUDPClient.cs]"]
  node_udpclient["UDP Client<br/>[UdpClient.cs]"]
  node_packet["Packet Protocol<br/>[Packet.cs]"]
  node_udpbase["UDP Transport<br/>[UdpBase.cs]"]
  node_listener["UDP Server Listener<br/>[UdpListener.cs]"]
  node_server["Server Application<br/>[Program.cs]"]
  node_players["Network Players<br/>[Player.cs]"]
end

node_player(("Player"))

node_player -->|"chooses mode"| node_launcher
node_launcher -->|"opens"| node_desktop
node_launcher -->|"opens"| node_ai
node_launcher -->|"opens"| node_udpform
node_player -->|"plays match"| node_desktop
node_player -->|"enters moves"| node_console
node_desktop -->|"renders board"| node_uihelpers
node_ai -->|"renders board"| node_uihelpers
node_udpform -->|"renders board"| node_uihelpers
node_desktop -->|"uses state"| node_board
node_console -->|"uses state"| node_board
node_ai -->|"uses state"| node_board
node_ai -->|"selects moves"| node_aialgorithms
node_uihelpers -->|"reads positions"| node_board
node_board -->|"stores pieces"| node_tile
node_board -->|"queries pieces"| node_pieceinterface
node_board -->|"generates moves"| node_move
node_board -->|"creates setup"| node_chess960
node_piece -->|"implements"| node_pieceinterface
node_piece -->|"tracks position"| node_location
node_pieces -->|"extends"| node_piece
node_pieces -->|"requests legal moves"| node_movement
node_movement -->|"checks positions"| node_board
node_game -->|"holds state"| node_board
node_udpform -->|"sends packets"| node_udpclient
node_udpform -->|"reads game update"| node_game
node_udpclient -->|"serializes packets"| node_packet
node_udpclient -->|"inherits transport"| node_udpbase
node_server -->|"uses listener"| node_listener
node_server -->|"manages match"| node_game
node_server -->|"assigns players"| node_players
node_listener -->|"handles packets"| node_packet
node_listener -->|"updates game"| node_game
node_player -->|"joins or hosts"| node_udpform

click node_launcher "https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormLauncher.cs"
click node_desktop "https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormPlayerVsPlayer.cs"
click node_ai "https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormAIvsAI.cs"
click node_console "https://github.com/ruskpr/chess/blob/master/Applications/ChessConsoleApp/Program.cs"
click node_uihelpers "https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/ChessUtils.cs"
click node_board "https://github.com/ruskpr/chess/blob/master/Chess.Core/Board.cs"
click node_tile "https://github.com/ruskpr/chess/blob/master/Chess.Core/Tile.cs"
click node_location "https://github.com/ruskpr/chess/blob/master/Chess.Core/BoardLocation.cs"
click node_game "https://github.com/ruskpr/chess/blob/master/Chess.Core/Game.cs"
click node_move "https://github.com/ruskpr/chess/blob/master/Chess.Core/Move.cs"
click node_piece "https://github.com/ruskpr/chess/blob/master/Chess.Core/Piece.cs"
click node_pieceinterface "https://github.com/ruskpr/chess/blob/master/Chess.Core/IPiece.cs"
click node_movement "https://github.com/ruskpr/chess/blob/master/Chess.Core/Movement.cs"
click node_pieces "https://github.com/ruskpr/chess/tree/master/Chess.Core/Pieces"
click node_chess960 "https://github.com/ruskpr/chess/blob/master/Chess.Core/Chess960/Chess960Generator.cs"
click node_aialgorithms "https://github.com/ruskpr/chess/tree/master/Chess.Core/Algorithms"
click node_udpform "https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormUDPClient.cs"
click node_udpclient "https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/UdpClient.cs"
click node_packet "https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/Packet.cs"
click node_udpbase "https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/UdpBase.cs"
click node_listener "https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/UdpListener.cs"
click node_server "https://github.com/ruskpr/chess/blob/master/Applications/ChessServer/Program.cs"
click node_players "https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/Player.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_launcher,node_desktop,node_ai,node_console,node_uihelpers toneBlue
class node_board,node_tile,node_location,node_game,node_move,node_piece,node_pieceinterface,node_movement,node_pieces,node_chess960,node_aialgorithms toneAmber
class node_udpform,node_udpclient,node_packet,node_udpbase,node_listener,node_server,node_players toneMint
class node_player toneIndigo
```

## Components

### Play Applications

- [Mode Launcher](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormLauncher.cs): `Applications/ChessClient/FormLauncher.cs`
- [Desktop Play](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormPlayerVsPlayer.cs): `Applications/ChessClient/FormPlayerVsPlayer.cs`
- [AI Match](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormAIvsAI.cs): `Applications/ChessClient/FormAIvsAI.cs`
- [Console Play](https://github.com/ruskpr/chess/blob/master/Applications/ChessConsoleApp/Program.cs): `Applications/ChessConsoleApp/Program.cs`
- [Board UI Helpers](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/ChessUtils.cs): `Applications/ChessClient/ChessUtils.cs`

### Chess Rules

- [Board State](https://github.com/ruskpr/chess/blob/master/Chess.Core/Board.cs): `Chess.Core/Board.cs`
- [Tiles](https://github.com/ruskpr/chess/blob/master/Chess.Core/Tile.cs): `Chess.Core/Tile.cs`
- [Board Coordinates](https://github.com/ruskpr/chess/blob/master/Chess.Core/BoardLocation.cs): `Chess.Core/BoardLocation.cs`
- [Game and Turns](https://github.com/ruskpr/chess/blob/master/Chess.Core/Game.cs): `Chess.Core/Game.cs`
- [Move Model](https://github.com/ruskpr/chess/blob/master/Chess.Core/Move.cs): `Chess.Core/Move.cs`
- [Piece Base](https://github.com/ruskpr/chess/blob/master/Chess.Core/Piece.cs): `Chess.Core/Piece.cs`
- [Piece Contract](https://github.com/ruskpr/chess/blob/master/Chess.Core/IPiece.cs): `Chess.Core/IPiece.cs`
- [Move Validation](https://github.com/ruskpr/chess/blob/master/Chess.Core/Movement.cs): `Chess.Core/Movement.cs`
- [Piece Rules](https://github.com/ruskpr/chess/tree/master/Chess.Core/Pieces): `Chess.Core/Pieces`
- [Chess960 Setup](https://github.com/ruskpr/chess/blob/master/Chess.Core/Chess960/Chess960Generator.cs): `Chess.Core/Chess960/Chess960Generator.cs`
- [AI Algorithms](https://github.com/ruskpr/chess/tree/master/Chess.Core/Algorithms): `Chess.Core/Algorithms`

### UDP Multiplayer

- [Network Client UI](https://github.com/ruskpr/chess/blob/master/Applications/ChessClient/FormUDPClient.cs): `Applications/ChessClient/FormUDPClient.cs`
- [UDP Client](https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/UdpClient.cs): `Chess.Core/UDP/UdpClient.cs`
- [Packet Protocol](https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/Packet.cs): `Chess.Core/UDP/Packet.cs`
- [UDP Transport](https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/UdpBase.cs): `Chess.Core/UDP/UdpBase.cs`
- [UDP Server Listener](https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/UdpListener.cs): `Chess.Core/UDP/UdpListener.cs`
- [Server Application](https://github.com/ruskpr/chess/blob/master/Applications/ChessServer/Program.cs): `Applications/ChessServer/Program.cs`
- [Network Players](https://github.com/ruskpr/chess/blob/master/Chess.Core/UDP/Player.cs): `Chess.Core/UDP/Player.cs`

### Other components

- **Player**

## Connections

- Player → Mode Launcher: chooses mode (evidence: `README.md`)
- Mode Launcher → Desktop Play: opens (evidence: `Applications/ChessClient/FormLauncher.cs`)
- Mode Launcher → AI Match: opens (evidence: `Applications/ChessClient/FormLauncher.cs`)
- Mode Launcher → Network Client UI: opens (evidence: `Applications/ChessClient/FormLauncher.cs`)
- Player → Desktop Play: plays match (evidence: `README.md`)
- Player → Console Play: enters moves (evidence: `README.md`)
- Desktop Play → Board UI Helpers: renders board (evidence: `Applications/ChessClient/FormPlayerVsPlayer.cs`)
- AI Match → Board UI Helpers: renders board (evidence: `Applications/ChessClient/FormAIvsAI.cs`)
- Network Client UI → Board UI Helpers: renders board (evidence: `Applications/ChessClient/FormUDPClient.cs`)
- Desktop Play → Board State: uses state (evidence: `Applications/ChessClient/FormPlayerVsPlayer.cs`)
- Console Play → Board State: uses state (evidence: `Applications/ChessConsoleApp/Program.cs`)
- AI Match → Board State: uses state (evidence: `Applications/ChessClient/FormAIvsAI.cs`)
- AI Match → AI Algorithms: selects moves (evidence: `Applications/ChessClient/FormAIvsAI.cs`)
- Board UI Helpers → Board State: reads positions (evidence: `Applications/ChessClient/ChessUtils.cs`)
- Board State → Tiles: stores pieces (evidence: `Chess.Core/Board.cs`)
- Board State → Piece Contract: queries pieces (evidence: `Chess.Core/Board.cs`)
- Board State → Move Model: generates moves (evidence: `Chess.Core/Board.cs`)
- Board State → Chess960 Setup: creates setup (evidence: `Chess.Core/Board.cs`)
- Piece Base → Piece Contract: implements (evidence: `Chess.Core/Piece.cs`)
- Piece Base → Board Coordinates: tracks position (evidence: `Chess.Core/Piece.cs`)
- Piece Rules → Piece Base: extends (evidence: `Chess.Core/Pieces/King.cs`)
- Piece Rules → Move Validation: requests legal moves (evidence: `Chess.Core/Pieces/King.cs`)
- Move Validation → Board State: checks positions (evidence: `Chess.Core/Movement.cs`)
- Game and Turns → Board State: holds state (evidence: `Chess.Core/Game.cs`)
- Network Client UI → UDP Client: sends packets (evidence: `Applications/ChessClient/FormUDPClient.cs`)
- Network Client UI → Game and Turns: reads game update (evidence: `Applications/ChessClient/FormUDPClient.cs`)
- UDP Client → Packet Protocol: serializes packets (evidence: `Chess.Core/UDP/UdpClient.cs`)
- UDP Client → UDP Transport: inherits transport (evidence: `Chess.Core/UDP/UdpClient.cs`)
- Server Application → UDP Server Listener: uses listener (evidence: `Applications/ChessServer/Program.cs`)
- Server Application → Game and Turns: manages match (evidence: `Applications/ChessServer/Program.cs`)
- Server Application → Network Players: assigns players (evidence: `Applications/ChessServer/Program.cs`)
- UDP Server Listener → Packet Protocol: handles packets (evidence: `Chess.Core/UDP/UdpListener.cs`)
- UDP Server Listener → Game and Turns: updates game (evidence: `Chess.Core/UDP/UdpListener.cs`)
- Player → Network Client UI: joins or hosts (evidence: `README.md`)
