# a6575/ci6450-ai-videogames-project architecture

> Architecture diagram of the GitHub repository a6575/ci6450-ai-videogames-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/a6575/ci6450-ai-videogames-project
- Repository: https://github.com/a6575/ci6450-ai-videogames-project

## Overview

##### Project type and purpose
- This is a single-player video game prototype built in Python 3.10+ using Pygame 2.6.1.
- It focuses on character movement and AI steering behaviors (kinematic and dynamic) for both the player avatar and NPCs.
- The goal is to demonstrate AI techniques within a game loop context (movement, rendering, input handling).

##### File structure
- Top level:
- assets/ – holds graphical and audio resources
- src/main.py – game entry point, initializes Pygame and starts the main loop
- src/imports/gui.py – graphical interface and rendering abstractions
- src/imports/player/player.py – Player class, input mapping, state
- src/imports/npc/npc.py – NPC class, state machine or behavior driver
- src/imports/moves/ – various steering-behavior modules, both kinematic and dynamic, plus a switcher
- No external services or databases, a self-contained monolith.
- requirements.txt declares Pygame dependency.

##### README for additional insights
- The README confirms the above structure.

##### Main components
a. Game Loop (main.py)
b. Input Handler (keyboard events → Player module)
c. Update Manager
- Player Controller
- NPC Controller
- Steering Behavior Engine (moves/*)
d. GUI / Renderer (gui.py + Pygame Surface)
e. Asset Manager (assets/)
f. External Library: Pygame

##### Relationships and interactions
- The Game Loop polls Input → forwards to Player Controller
- Game Loop invokes Update Manager:
- Player Controller queries Steering Behavior Engine for next velocity/position
- NPC Controller uses Steering Behavior Engine via “switcher” to choose behaviors dynamically
- Update Manager updates entity states
- Renderer draws current state using GUI module and loaded assets
- Loop repeats at fixed timestep or frame cap

##### Architectural patterns and design principles
- Component-based separation:
- Input
- Logic (AI & movement)
- Rendering
- Single Responsibility Principle: each module handles one concern
- Strategy pattern for steering behaviors: interchangeable kinematic vs. dynamic
- Centralized main loop coordinating subsystems

##### Technologies, frameworks, libraries
- Python 3.10+
- Pygame 2.6.1
- Custom modules under src/imports

##### Detailed checklist
- [ ] Input Handler block
- [ ] Player and NPC blocks under “Entities”
- [ ] Steering Behavior Engine block with sub-modules (list kinematic_/dynamic_)
- [ ] GUI/Renderer block linked to Pygame API and assets
- [ ] Pygame external library

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "src/"
    direction TB
    GameLoop["Game Loop\ninitialize()\nhandle_input()\nupdate()\nrender()"]:::core
    InputHandler["Input Handler"]:::core
    UpdateManager["Update Manager"]:::core
    PlayerController["Player Controller"]:::domain
    NPCController["NPC Controller"]:::domain
    SteeringEngine["Steering Behavior Engine"]:::utility
    GUIRenderer["GUI / Renderer"]:::core
  end
  AssetManager[(Assets)]:::assets
  PygameLib["Pygame"]:::external

  GameLoop -->|"event"| InputHandler
  InputHandler -->|"processInput"| PlayerController
  GameLoop -->|"update()"| UpdateManager
  UpdateManager -->|"update()"| PlayerController
  UpdateManager -->|"update()"| NPCController
  PlayerController -->|"computeBehavior()"| SteeringEngine
  NPCController -->|"computeBehavior()"| SteeringEngine
  UpdateManager -->|"render()"| GUIRenderer
  GUIRenderer -->|"load()"| AssetManager
  GUIRenderer -->|"uses"| PygameLib

  click GameLoop "https://github.com/a6575/ci6450-ai-videogames-project/blob/main/src/main.py"
  click InputHandler "https://github.com/a6575/ci6450-ai-videogames-project/blob/main/src/imports/player/player.py"
  click PlayerController "https://github.com/a6575/ci6450-ai-videogames-project/blob/main/src/imports/player/player.py"
  click NPCController "https://github.com/a6575/ci6450-ai-videogames-project/blob/main/src/imports/npc/npc.py"
  click SteeringEngine "https://github.com/a6575/ci6450-ai-videogames-project/tree/main/src/imports/moves/"
  click GUIRenderer "https://github.com/a6575/ci6450-ai-videogames-project/blob/main/src/imports/gui.py"
  click AssetManager "https://github.com/a6575/ci6450-ai-videogames-project/tree/main/assets/"
  click PygameLib "https://github.com/a6575/ci6450-ai-videogames-project/blob/main/requirements.txt"

  classDef core fill:#bbdefb,stroke:#0d47a1,stroke-width:2px
  classDef domain fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px
  classDef utility fill:#fff9c4,stroke:#f9a825,stroke-width:2px
  classDef assets fill:#e0e0e0,stroke:#616161,stroke-width:2px
  classDef external fill:#b3e5fc,stroke:#0277bd,stroke-width:2px
```
