How alexis2707/projet_divercite works
Project Type and Purpose
• This is a monolithic Python‐based board‐game application (“Divercite”) that bundles:
• A game engine (board rules, game‐state management, scoring, validation)
• A set of player implementations (random, greedy, advanced AI, legacy agents)
• A controller/CLI entry‐point (main_divercite.py, master_divercite.py)
• A GUI frontend (static HTML/CSS/JS)
• An optional networking layer for remote multiplayer (via aiohttp)
• Its goal is to let users run local matches (human vs. human or AI), host/join remote games, and experiment with AI strategies.
File‐Structure Analysis
• Top‐Level Python Modules:
• board_divercite.py – Board representation & rule enforcement
• game_state_divercite.py – State transitions, move validation, scoring
• player_divercite.py – Base class for any player
• random_player_divercite.py, greedy_player_divercite.py, my_player.py – Concrete strategies
• legacy_agent/ – Historical variants (v0 → v3) of an agent for benchmarking
• master_divercite.py – Orchestrates a full match, declares winner
• main_divercite.py – CLI/parser, selects mode (local, human_vs_computer, host/join, human_vs_human)
• GUI Directory:
• index.html, main.css, main.js, assets – Static SPA for interactive play
• Config & Docs: requirements.txt, .gitignore, project PDFs for design/rapport
README Insights
• Supports four play modes: local, human_vs_computer, human_vs_human, remote multiplayer (host/connect)
• Emphasizes modular players—swapping strategy by passing different .py files on the command line
• Mentions logging/state‐recording, hints at extensibility through base player class and legacy agents
a. Main Components to Include
• Controller Layer
– CLI Handler (main_divercite.py + seahorse parser)
– Match Manager (master_divercite.py)
• Game Engine (Core)
– Board Module (board_divercite.py)
– Game State Manager (game_state_divercite.py)
– Rule & Scoring Subsystem
• Player Components
– Base Player Interface (player_divercite.py)
– Strategy Plugins (random, greedy, my_player, legacy_agent/*)
• UI Layer
– CLI Output (colorama + loguru)
– GUI Frontend (index.html, main.js served locally or via aiohttp)
• Networking Layer (aiohttp)
– Host Service (listening socket)
– Client Connector (outbound)
• Logging & Persistence
– loguru logger writing to console/files
b. Relationships & Data Flows
• Controller → Game Engine: “startMatch(config)”, “nextTurn()”
• Game Engine ↔ Player: “requestMove(state) → move”, “validateMove”
• Game Engine → State Manager → Scoring → Controller
• Controller ↔ UI Layer: updates, user input events
• Controller ↔ Networking: emit/receive move events for remote play
• All components → Logger: event logs
c. Architectural Patterns & Principles
• Modular design: Swappable player strategies via a common interface (Strategy pattern)
• Separation of concerns:
– Model (board & state)
– Controller (match orchestration)
– View (CLI, GUI)
• Plugin architecture for AI agents (drop-in .py scripts)
• Event-driven IO for multiplayer (async via aiohttp)
d. Key Technologies/Frameworks
• Python modules & packages
• asyncio + aiohttp for networking
• seahorse for CLI command parsing & interactive shell
• loguru for structured logging
• colorama for CLI coloring
• Vanilla Web tech (HTML/CSS/JS) for front end