# multigriffes/sous-marinthe-premiere architecture

> Architecture diagram of the GitHub repository multigriffes/sous-marinthe-premiere, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/multigriffes/sous-marinthe-premiere
- Repository: https://github.com/multigriffes/sous-marinthe-premiere

## Overview

##### Main Components
- Game Initialization & Input Handling – This includes the main loop (play()) that handles user inputs (size of grid, starting coordinates, movement commands) and validates them.
- Grid and Map Creation – The creation_grille_joueur() function is responsible for generating the game grid, placing the player ('O') and, for the second variant, the exit ('S'). Include the random map selection from a list of maps generated elsewhere (see generation_liste_maps.py).
- Game Logic & Movement – The action() function contains the primary game logic: verifying movement directions, checking for walls, updating the player’s position, and handling score counters (nbr_etoiles and nbr_murs). There are slight differences between the two consignes here (e.g., resetting the player's position when hitting a wall in the 2nd version).
- /Rendering – The affichage() function outputs the current state of the grid along with counters and debug separators to the console.
- Creation/Documentation – Although less central to the runtime mechanics, the project also includes documentation files and a separate Python file (generation_liste_maps.py) for handling map generation.

##### Relationships and Interactions
- The play() function acts as the orchestrator; it first gathers input, then calls creation_grille_joueur() for initial setup.
- Once the game is set up, play() enters a loop: it calls affichage() to render the game state, takes new movement commands from the user, and then calls action() to update the game state based on those commands.
- The updated state is then displayed again. The game logic in action() sometimes involves resetting the position (2nd consigne) or updating score counters.
- Every module (initialization, game logic, input, display) works together in a sequential flow controlled by the main loop.

##### Relevant Technologies and Frameworks
- Python is the language, and the design is procedural (functional decomposition into clear functions).
- The random module is utilized (via randint) for generating random player positions and with maps.
- The UI is text-based (console input/output), so your display component is a CLI rendering pipeline.

##### What
- A clear label for each component (e.g., “User Input & Validation”, “Grid and Map Generator”, “Game Logic/Movement Handler”, “Display/Render Engine”).
- Notes on external dependencies (e.g., random number generation for map selection, Python’s input() function for user inputs).
- A branch indicating the decision based on chosen consigne, differentiating the scoring update and movement reset behavior.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Setup Phase
    A["Game Initialization & Input Handling (play())"]:::initialization
    M["Map List Generation"]:::generator
    B["Grid and Map Creation (creation_grille_joueur)"]:::generator

    %% Game Loop Phase
    D["Display/Rendering Engine (affichage())"]:::gameloop
    U["User Movement Input"]:::gameloop
    C["Game Logic & Movement Handler (action())"]:::gameloop
    E["Game Mode Decision"]:::decision
    E1["1ère consigne: Star Collection"]:::decision
    E2["2ème consigne: Exit & Reset"]:::decision

    %% Documentation
    F["Map Documentation & Support"]:::documentation
    G["Additional Support Document"]:::documentation

    %% Flow Connections
    A --> M
    M --> B
    B --> D
    D --> U
    U --> C
    C --> E
    E -->|"1ere"| E1
    E -->|"2eme"| E2
    E1 --> D
    E2 --> D

    %% Documentation Connections
    M -.->|"docs"| F
    F -.-> G

    %% Click Events (Paths for components)
    click A "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/non_visuel_1er_consigne.py"
    click B "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/non_visuel_1er_consigne.py/non_visuel_2eme_consigne.py"
    click C "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/non_visuel_1er_consigne.py"
    click D "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/non_visuel_1er_consigne.py"
    click E2 "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/non_visuel_2eme_consigne.py"
    click M "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/generation_liste_maps.py"
    click F "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/Documentation.txt"
    click G "https://github.com/multigriffes/sous-marinthe-premiere/blob/master/Sous-marinthe.docx"

    %% Styles
    classDef initialization fill:#FFCCCB,stroke:#333,stroke-width:2px;
    classDef generator fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef gameloop fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef decision fill:#FFD580,stroke:#333,stroke-width:2px;
    classDef documentation fill:#E6E6FA,stroke:#333,stroke-width:2px;
```
