# rs-gty/peg-solitaire architecture

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

- Interactive diagram: https://gitdiagram.com/rs-gty/peg-solitaire
- Repository: https://github.com/rs-gty/peg-solitaire

## Overview

Peg Solitaire is a small graphical game: the user clicks a peg and then an empty cell to attempt a jump. The application initializes the grid and window, registers mouse callbacks, and runs the window event loop. Window translates mouse coordinates and dispatches registered events; the selection callback updates grid state and clears the moved-from and jumped-over cells, while the window redraws pegs and checks for closure. The excerpts show these runtime relationships; the README is empty, so no additional documented capabilities are available.

Main entry points: [`Peg Solitaire/Window.cpp`](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Window.cpp) (Window Loop), [`Peg Solitaire/Grid.cpp`](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Grid.cpp) (Peg Grid), [`Peg Solitaire/main.cpp`](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/main.cpp) (Game Entry), [`Peg Solitaire/Event.cpp`](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Event.cpp) (Event Registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Game Entry<br/>[main.cpp]"]
  node_select["Selection Callback<br/>[main.cpp]"]
end

subgraph group_interaction["Input and Events"]
  node_mouse["Mouse Mapping<br/>[Window.cpp]"]
  node_events["Event Registry<br/>[Event.cpp]"]
end

subgraph group_game["Game State"]
  node_grid["Peg Grid<br/>[Grid.cpp]"]
end

subgraph group_display["Window Display"]
  node_window["Window Loop<br/>[Window.cpp]"]
  node_drawing["Grid and Peg Drawing<br/>[Window.cpp]"]
end

node_user(("Player"))
node_easyx["EasyX Graphics"]

node_user -->|"sends mouse input"| node_window
node_main -->|"starts and listens"| node_window
node_main -->|"creates grid"| node_grid
node_main -->|"registers callbacks"| node_events
node_window -->|"maps coordinates"| node_mouse
node_window -->|"sets mouse position"| node_grid
node_window -->|"triggers events"| node_events
node_events -->|"invokes callback"| node_select
node_select -->|"selects and moves"| node_grid
node_select -->|"clears moved cells"| node_window
node_window -->|"draws each loop"| node_drawing
node_drawing -->|"reads peg state"| node_grid
node_window -->|"draws graphics"| node_easyx

click node_main "https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/main.cpp"
click node_window "https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Window.cpp"
click node_mouse "https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Window.cpp"
click node_events "https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Event.cpp"
click node_select "https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/main.cpp"
click node_grid "https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Grid.cpp"
click node_drawing "https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Window.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_main,node_select toneBlue
class node_mouse,node_events toneAmber
class node_grid toneMint
class node_window,node_drawing toneRose
class node_user,node_easyx toneIndigo
```

## Components

### Application

- [Game Entry](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/main.cpp): `Peg Solitaire/main.cpp`
- [Selection Callback](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/main.cpp): `Peg Solitaire/main.cpp`

### Input and Events

- [Mouse Mapping](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Window.cpp): `Peg Solitaire/Window.cpp`
- [Event Registry](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Event.cpp): `Peg Solitaire/Event.cpp`

### Game State

- [Peg Grid](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Grid.cpp): `Peg Solitaire/Grid.cpp`

### Window Display

- [Window Loop](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Window.cpp): `Peg Solitaire/Window.cpp`
- [Grid and Peg Drawing](https://github.com/rs-gty/peg-solitaire/blob/master/Peg%20Solitaire/Window.cpp): `Peg Solitaire/Window.cpp`

### Other components

- **Player**
- **EasyX Graphics**

## Connections

- Player → Window Loop: sends mouse input (evidence: `Peg Solitaire/Window.cpp`)
- Game Entry → Window Loop: starts and listens (evidence: `Peg Solitaire/main.cpp`)
- Game Entry → Peg Grid: creates grid (evidence: `Peg Solitaire/main.cpp`)
- Game Entry → Event Registry: registers callbacks (evidence: `Peg Solitaire/main.cpp`)
- Window Loop → Mouse Mapping: maps coordinates (evidence: `Peg Solitaire/Window.cpp`)
- Window Loop → Peg Grid: sets mouse position (evidence: `Peg Solitaire/Window.cpp`)
- Window Loop → Event Registry: triggers events (evidence: `Peg Solitaire/Window.cpp`)
- Event Registry → Selection Callback: invokes callback (evidence: `Peg Solitaire/Event.cpp`)
- Selection Callback → Peg Grid: selects and moves (evidence: `Peg Solitaire/main.cpp`)
- Selection Callback → Window Loop: clears moved cells (evidence: `Peg Solitaire/main.cpp`)
- Window Loop → Grid and Peg Drawing: draws each loop (evidence: `Peg Solitaire/Window.cpp`)
- Grid and Peg Drawing → Peg Grid: reads peg state (evidence: `Peg Solitaire/Window.cpp`)
- Window Loop → EasyX Graphics: draws graphics (evidence: `Peg Solitaire/Window.cpp`)
