How multigriffes/sous-marinthe-premiere works
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.