How brandonpike/uc-berkeley-pacman works
The Pacman AI project is centered on building and testing search algorithms within a maze environment where Pacman finds paths (e.g., to dots or corners) using classic search techniques such as Depth First Search (DFS), Breadth First Search (BFS), Uniform Cost Search (UCS), and A*. The project is organized as a command-line game with both graphical and text-based displays, and it also includes components for automated grading and testing.
Main Components
• Main Execution and Game Engine:
• pacman.py – the central entry point that initializes the game, processes command-line arguments, and launches the game loop.
• game.py – contains the core logic for game flow and mechanics.
• Agents and Search Algorithms:
• search.py, searchAgents.py, pacmanAgents.py, and ghostAgents.py – these files encapsulate the implementation of search algorithms and handle different types of agents (Pacman, ghosts, etc.).
• keyboardAgents.py – allows interactive control via user input.
• Maze/Layouts:
• layout.py and the layouts directory (including its duplicate under the project’s root) – these contain the maze definitions (.lay files) that configure the game environments.
• Components:
• graphicsDisplay.py and graphicsUtils.py – manage the graphical interface and display.
• textDisplay.py – handles rendering of the game in a text-based format.
• Testing/Grading Infrastructure:
• autograder.py, grading.py, testClasses.py, testParser.py, and searchTestClasses.py – support automated scoring, testing, and validation of search algorithms.
• Support/Utility Components:
• util.py and projectParams.py – provide helper functions and configuration parameters.
• eightpuzzle.py – possibly supports an auxiliary puzzle challenge which may share search techniques.
Relationships and Data Flow
• The User invokes the program via the command line (e.g., “python pacman.py –l tinyMaze –p SearchAgent –a fn=astar,heuristic=manhattanHeuristic”). This triggers command-line argument parsing.
• pacman.py then initializes the Game Engine (central game loop in game.py) and loads a maze layout from the layout files.
• The Game Engine coordinates with the Search Algorithms (from search.py and searchAgents.py) to compute the shortest path for the Pacman agent. Different agent files (pacmanAgents.py, ghostAgents.py, keyboardAgents.py) plug into game.py based on user input.
• The Display components (either graphicsDisplay.py/graphicsUtils.py or textDisplay.py) render the current state of the game.
• Simultaneously, testing (e.g., autograder.py, testParser.py) can be invoked to validate the agent behavior and grading for educational purposes.
Architectural Patterns and Design Principles
• Separation of Concerns: The project distinctly divides responsibilities among modules—input handling, game logic, search algorithms, display, and testing—making it easier to track and modify each part independently.
• Modularity and Extensibility: The use of different agent types (SearchAgent, AStarCornersAgent, etc.) and easily configurable layouts (.lay files) indicates a design that supports plug-and-play extension.
• Command-line Configuration: The system heavily relies on command-line arguments to switch and test different behaviors, which is essential for experimental algorithms.
Final Checklist for the Principal Software Engineer
• Clear, descriptive labels for each component.
• On the modular design (separation of concerns and extensibility) in your architectural layout.
• Configuration or initialization flows pertinent to switching between different search strategies and maze layouts.