# ilyaan-umatia/eater-passer-game architecture

> Architecture diagram of the GitHub repository ilyaan-umatia/eater-passer-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ilyaan-umatia/eater-passer-game
- Repository: https://github.com/ilyaan-umatia/eater-passer-game

## Overview

##### Project Type and Purpose
- This is a single‐executable, console‐based C program implementing a two‐player strategy board game (“Eater and Passer”).
- It is neither a client/server nor a multi‐service system—it’s a monolithic, command‐line application demonstrating game logic, board state management, player input, and AI strategies.

##### High-Level Architectural Components
A. Game Controller
- Orchestrates the main game loop
- Invokes input, state update, win‐check, and rendering
B. Board State Manager
- Maintains the 2D array representing the board
- Provides functions to initialize and update cells
C. Player Input Handler
- Reads and validates human moves from stdin
D. AI Strategy Module
- Implements two strategy submodules:
– RandomPlayer (random valid move)
– StraightLinePlayer (greedy top‐to‐bottom path)
E. Win Condition Checker
F. Console Renderer
- Renders the 2D board array in the console after each move

##### Relationships and Data Flows
- The Game Controller sits at the center.
- It first calls the Board State Manager to initialize the board.
- In each turn:
a. Game Controller → Player Input Handler or AI Module (based on whose turn)
b. Player Module → Game Controller (returns chosen move)
c. Game Controller → Board State Manager (apply move)
d. Game Controller → Win Condition Checker (check for victory)
f. Loop until Win Condition Checker signals game end

##### Architectural Patterns and Principles
- Single Responsibility: each module has a well‐defined role (e.g., rendering vs. logic).
- Strategy Pattern (informal C‐style): the AI Strategy Module can swap in different “player” implementations without touching the Controller.
- Data Encapsulation: the Board State Manager abstracts the underlying 2D array.

##### Technologies and Key Constructs
- Language: C
- Data Structure: 2D array for board representation
- Control Flow: main game loop, switch between human and AI turns
- I/O: `printf`/`scanf` (or similar) for console I/O
- Algorithms: DFS/graph‐search or greedy pathfinding for win check and StraightLinePlayer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Main Controller
    GameController["Game Controller"]:::logic
    click GameController "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/Eater-Passer Code.c"

    %% Surrounding Modules
    BoardState["Board State Manager"]:::data
    click BoardState "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/Eater-Passer Code.c"

    PlayerInput["Player Input Handler"]:::io
    click PlayerInput "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/Eater-Passer Code.c"

    subgraph "AI Strategy Module"
        direction TB
        RandomPlayer["RandomPlayer"]:::ai
        StraightLine["StraightLinePlayer"]:::ai
        click RandomPlayer "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/Eater-Passer Code.c"
        click StraightLine "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/Eater-Passer Code.c"
    end

    WinChecker["Win Condition Checker"]:::logic
    click WinChecker "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/Eater-Passer Code.c"

    Renderer["Console Renderer"]:::io
    click Renderer "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/Eater-Passer Code.c"

    Documentation["Project Documentation (README)"]:::doc
    click Documentation "https://github.com/ilyaan-umatia/eater-passer-game/blob/main/README.md"

    %% Relationships / Data Flows
    GameController -->|"initializeBoard()"| BoardState
    GameController -->|"getMove() (Human)"| PlayerInput
    GameController -->|"getMove() (AI)"| RandomPlayer
    GameController -->|"getMove() (AI)"| StraightLine
    RandomPlayer -->|"moveChoice"| GameController
    StraightLine -->|"moveChoice"| GameController
    PlayerInput -->|"moveChoice"| GameController
    GameController -->|"applyMove()"| BoardState
    GameController -->|"checkWin()"| WinChecker
    GameController -->|"drawBoard()"| Renderer
    GameController --> BoardState

    %% Legend
    subgraph Legend
        L1["Logic Modules"]:::logic
        L2["Data Module"]:::data
        L3["I/O Modules"]:::io
        L4["AI Strategy Modules"]:::ai
        L5["Documentation"]:::doc
    end

    classDef logic fill:#f9f,stroke:#333,stroke-width:1px
    classDef data  fill:#9ff,stroke:#333,stroke-width:1px
    classDef io    fill:#ff9,stroke:#333,stroke-width:1px
    classDef ai    fill:#cfc,stroke:#333,stroke-width:1px
    classDef doc   fill:#ccc,stroke:#333,stroke-width:1px
```
