How yan25-06/project2_wumpus works
Project Type and Purpose
• This is a Python-based simulation/game framework implementing the “Wumpus World.”
• It provides both a command-line mode and a GUI mode for playing/testing agent behaviors (random, hybrid, etc.).
• Core functionality includes world/environment modeling, AI inference and planning, and a visual interface.
Top-Level Components
• wumpus/main.py → entry point (CLI or GUI launcher)
• wumpus/config/settings.py → global configuration (game settings, scoring, orientations)
• wumpus/core/environment.py→ world model & state transitions
• wumpus/ai/* → inference_engine, knowledge_base, planning_module, rules_parser
• wumpus/agents/* → agent interface + implementations (random_agent, hybrid_agent)
• wumpus/GUI/* → UI layers (setup_ui, draw_ui, game_board, button_functions)
• saved_envs/ → persisted probability maps and checkpoints (pickled)
• facts.txt, rules.txt → domain definitions for inference engine
• tests/ → unit tests for AI, agents, and models
Key Interactions and Data Flow
• User invokes wumpus.main → loads settings → chooses headless or GUI
• Main creates Environment instance (model) and Agent instance (controller)
• If GUI mode: setup_ui initializes windows → draw_ui renders board → button_functions dispatch user actions
• On each turn:
• Agent.request_percept() pulls sensor data from Environment
• Agent calls inference_engine & planning_module using knowledge_base & rules_parser
• Agent decides on next action → calls environment.act(action)
• Environment updates world state & returns new percepts
• UI listens for state changes, re-renders the board after each move
• saved_envs files are loaded by inference_engine or planning_module to bootstrap probabilities
Architectural Patterns & Principles
• MVC-style separation:
• Model = core/environment + saved_envs data
• View = GUI modules
• Controller = main.py + agents + AI modules
• Plugin-style agents: agent.py defines interface, new agents can be added easily
• Data-driven rules: rules.txt & facts.txt parsed at runtime by rules_parser
• Single responsibility: each module focuses on one concern (UI, AI, config, core, agents)