How etturo/pacman works
Pacman is a Pygame desktop game. The main loop loads settings, routes input and game events through distinct screens, updates gameplay (including maze, entities, scoring and level transitions), then renders and presents each frame. Players can also start AI play; the game supports persistent highscores, configurable sound sets and CRT-style display effects. The README documents these capabilities, while sampled source and the source index support the main runtime links. Some subsystem wiring is documented rather than directly excerpted, so those links cite the README; unsampled details are not inferred.
Main entry points: game_state.py Game states · game.py Game loop · maze.py Maze grid · agent.py AI agent
Components 23
Game runtime
- Game loop
src/core/game.py - Game states
src/core/game_state.py - Highscores
src/core/game_state.py
Gameplay systems
- Maze generation
src/world/maze_wrapper.py - Maze grid
src/world/maze.py - Maze cells
src/world/cell.py - Pac-Man
src/entities/pacman.py - Ghost behavior
src/entities/ghost.py - Ghost movement
src/entities/ghost_movement.py - Pac-gums
src/entities/pacgums.py
Presentation
- Maze renderer
src/graphics/maze_render.py - Display effects
src/graphics/screen_manager.py - Sprite assets
src/graphics/graphical_utils/sprite_library.py - Sprite sheets
src/graphics/graphical_utils/sprite_sheet.py - Game interface
src/graphics/ui/element.py - Sound sets
src/sounds/sound_library.py - Sound effects
src/sounds/sound_effects.py
Configuration and AI
- Settings parser
src/utils/parser.py - Settings model
src/utils/models.py - AI agent
src/ai/agent.py - AI context
src/ai/context.py - AI features
src/ai/features.py
Other components
- Player
Connections 25
- Player → Game loop: starts
- Game loop → Settings parser: loads config
src/core/game.py - Settings parser → Settings model: validates
src/utils/parser.py - Game loop → Game states: routes events
src/core/game.py - Game states → Maze generation: builds levels
src/core/game_state.py - Maze generation → Maze grid: adapts output
src/world/maze_wrapper.py - Maze grid → Maze cells: stores grid
src/world/maze.py - Game states → Pac-Man: updates
src/core/game_state.py - Game states → Ghost behavior: updates
src/core/game_state.py - Game states → Pac-gums: updates
src/core/game_state.py - Ghost behavior → Ghost movement: chooses movement
src/entities/ghost.py - Ghost movement → Maze grid: reads paths
src/entities/ghost_movement.py - Game states → Highscores: saves results
src/core/game_state.py - Game states → AI agent: requests actions
src/core/game_state.py - AI agent → AI context: uses context
src/ai/agent.py - AI agent → AI features: extracts features
src/ai/agent.py - AI context → Maze grid: reads maze
src/ai/context.py - Game states → Maze renderer: renders maze
src/core/game_state.py - Game states → Game interface: draws interface
src/core/game_state.py - Game loop → Display effects: presents frames
src/core/game.py - Maze renderer → Sprite assets: uses sprites
src/graphics/maze_render.py - Sprite assets → Sprite sheets: loads sheets
src/graphics/graphical_utils/sprite_library.py - Game loop → Sound sets: loads sounds
src/core/game.py - Sound sets → Sound effects: selects effects
src/sounds/sound_library.py - Game states → Sound sets: plays cues
src/core/game_state.py