I promised to post the code that got this result on the trickyFood
problem.
This is the line that runs the trickyFood
problem in the pacman.py
file.
args = readCommand(['-l', 'trickyFood', '-p', 'AStarFoodSearchAgent', '-z', '0.65'])
Path found with total cost of 60 in 0.2 seconds
Search nodes expanded: 206
Pacman emerges victorious! Score: 570
(This code got 26/25 from the autograder.)
Four files are attached: pacman.py, problems.py
(where I gathered all the problems), search.py
, and searchAgents.py
. (Some of the imports in other files may need adjustment since I moved some functions and classes around a bit.)
The food heuristic is generalized and is called the blobHeuristic
. It's in search.py
. The result above also depends on the priority function, which is associated with A*. It's in aStarSearch
, also in search.py
.
The corners problem and the food problem both use the blobHeuristic
since they are essentially the same problem: visit a given set of grid positions.
Post questions if you have any.