# marga8608/simulation-python- architecture

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

- Interactive diagram: https://gitdiagram.com/marga8608/simulation-python-
- Repository: https://github.com/marga8608/simulation-python-

## Overview

This repository implements a Pygame farming game: the player plants and harvests carrots while avoiding bunnies that seek and eat ready crops. The runtime starts in a play screen, handles keyboard and mouse input, creates the game world, updates its sprites, and renders the result until the player runs out of coins with no active crops. The graph preserves the distinct player, crop-growth, herbivore, scoring, and rendering responsibilities. Graphics assets referenced by source are not present as runtime image files in the supplied tree, so they are not mapped as working components.

Main entry points: [`game_functions.py`](https://github.com/marga8608/simulation-python-/blob/main/game_functions.py) (World setup), [`main.py`](https://github.com/marga8608/simulation-python-/blob/main/main.py) (Game loop), [`player.py`](https://github.com/marga8608/simulation-python-/blob/main/player.py) (Player controls), [`herbivore.py`](https://github.com/marga8608/simulation-python-/blob/main/herbivore.py) (Bunny behavior)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_game_loop["Game loop<br/>[main.py]"]
  node_event_handling["Event handling<br/>[game_functions.py]"]
  node_world_setup["World setup<br/>[game_functions.py]"]
  node_sprite_updates["Sprite updates<br/>[game_functions.py]"]
end

subgraph group_simulation["Game simulation"]
  node_player["Player controls<br/>[player.py]"]
  node_herbivore["Bunny behavior<br/>[herbivore.py]"]
  node_creature["Creature movement<br/>[creature.py]"]
  node_planter["Crop growth<br/>[planter.py]"]
  node_static_object["Static objects<br/>[static_object.py]"]
  node_scoreboard["Game score<br/>[score_board.py]"]
end

subgraph group_presentation["Display and settings"]
  node_rendering["Screen rendering<br/>[game_functions.py]"]
  node_settings["Game settings<br/>[settings.py]"]
end

node_player_actor(("Player"))

node_player_actor -.->|"sends input"| node_event_handling
node_game_loop -->|"checks events"| node_event_handling
node_game_loop -->|"creates world"| node_world_setup
node_game_loop -->|"updates sprites"| node_sprite_updates
node_game_loop -->|"renders frame"| node_rendering
node_game_loop -->|"creates settings"| node_settings
node_event_handling -->|"sets movement"| node_player
node_world_setup -->|"creates player"| node_player
node_world_setup -->|"creates bunnies"| node_herbivore
node_world_setup -->|"creates planters"| node_planter
node_world_setup -->|"creates walls"| node_static_object
node_world_setup -->|"creates score"| node_scoreboard
node_player -->|"inherits movement"| node_creature
node_herbivore -->|"inherits movement"| node_creature
node_planter -->|"inherits object"| node_static_object
node_player -->|"plants or harvests"| node_planter
node_player -->|"updates score"| node_scoreboard
node_herbivore -->|"eats ready crops"| node_planter
node_herbivore -->|"records eating"| node_scoreboard
node_sprite_updates -->|"updates group"| node_herbivore
node_sprite_updates -->|"updates group"| node_planter
node_rendering -->|"draws score"| node_scoreboard

click node_game_loop "https://github.com/marga8608/simulation-python-/blob/main/main.py"
click node_event_handling "https://github.com/marga8608/simulation-python-/blob/main/game_functions.py"
click node_world_setup "https://github.com/marga8608/simulation-python-/blob/main/game_functions.py"
click node_sprite_updates "https://github.com/marga8608/simulation-python-/blob/main/game_functions.py"
click node_player "https://github.com/marga8608/simulation-python-/blob/main/player.py"
click node_herbivore "https://github.com/marga8608/simulation-python-/blob/main/herbivore.py"
click node_creature "https://github.com/marga8608/simulation-python-/blob/main/creature.py"
click node_planter "https://github.com/marga8608/simulation-python-/blob/main/planter.py"
click node_static_object "https://github.com/marga8608/simulation-python-/blob/main/static_object.py"
click node_scoreboard "https://github.com/marga8608/simulation-python-/blob/main/score_board.py"
click node_rendering "https://github.com/marga8608/simulation-python-/blob/main/game_functions.py"
click node_settings "https://github.com/marga8608/simulation-python-/blob/main/settings.py"

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_game_loop,node_event_handling,node_world_setup,node_sprite_updates toneBlue
class node_player,node_herbivore,node_creature,node_planter,node_static_object,node_scoreboard toneAmber
class node_rendering,node_settings toneMint
class node_player_actor toneIndigo
```

## Components

### Game runtime

- [Game loop](https://github.com/marga8608/simulation-python-/blob/main/main.py): `main.py`
- [Event handling](https://github.com/marga8608/simulation-python-/blob/main/game_functions.py): `game_functions.py`
- [World setup](https://github.com/marga8608/simulation-python-/blob/main/game_functions.py): `game_functions.py`
- [Sprite updates](https://github.com/marga8608/simulation-python-/blob/main/game_functions.py): `game_functions.py`

### Game simulation

- [Player controls](https://github.com/marga8608/simulation-python-/blob/main/player.py): `player.py`
- [Bunny behavior](https://github.com/marga8608/simulation-python-/blob/main/herbivore.py): `herbivore.py`
- [Creature movement](https://github.com/marga8608/simulation-python-/blob/main/creature.py): `creature.py`
- [Crop growth](https://github.com/marga8608/simulation-python-/blob/main/planter.py): `planter.py`
- [Static objects](https://github.com/marga8608/simulation-python-/blob/main/static_object.py): `static_object.py`
- [Game score](https://github.com/marga8608/simulation-python-/blob/main/score_board.py): `score_board.py`

### Display and settings

- [Screen rendering](https://github.com/marga8608/simulation-python-/blob/main/game_functions.py): `game_functions.py`
- [Game settings](https://github.com/marga8608/simulation-python-/blob/main/settings.py): `settings.py`

### Other components

- **Player**

## Connections

- Player → Event handling: sends input
- Game loop → Event handling: checks events (evidence: `main.py`)
- Game loop → World setup: creates world (evidence: `main.py`)
- Game loop → Sprite updates: updates sprites (evidence: `main.py`)
- Game loop → Screen rendering: renders frame (evidence: `main.py`)
- Game loop → Game settings: creates settings (evidence: `main.py`)
- Event handling → Player controls: sets movement (evidence: `game_functions.py`)
- World setup → Player controls: creates player (evidence: `game_functions.py`)
- World setup → Bunny behavior: creates bunnies (evidence: `game_functions.py`)
- World setup → Crop growth: creates planters (evidence: `game_functions.py`)
- World setup → Static objects: creates walls (evidence: `game_functions.py`)
- World setup → Game score: creates score (evidence: `game_functions.py`)
- Player controls → Creature movement: inherits movement (evidence: `player.py`)
- Bunny behavior → Creature movement: inherits movement (evidence: `herbivore.py`)
- Crop growth → Static objects: inherits object (evidence: `planter.py`)
- Player controls → Crop growth: plants or harvests (evidence: `player.py`)
- Player controls → Game score: updates score (evidence: `player.py`)
- Bunny behavior → Crop growth: eats ready crops (evidence: `herbivore.py`)
- Bunny behavior → Game score: records eating (evidence: `herbivore.py`)
- Sprite updates → Bunny behavior: updates group (evidence: `game_functions.py`)
- Sprite updates → Crop growth: updates group (evidence: `game_functions.py`)
- Screen rendering → Game score: draws score (evidence: `game_functions.py`)
