Question: Design a heuristic evaluation function for pacman AI agent. List the factors you want to add to the heuristic function Factors: a ) distance to
Design a heuristic
evaluation function for pacman AI
agent. List the factors you want to
add to the heuristic function
Factors:
a distance to ghost
distance to food, distance to capsule the earlier
to get the capsule, the higher point the pacman
can get
b Weight for each factor
Wghost Wcapsule W food
c H wfwf
Hdghost dCapdFood
code that needs to be modified:
def evalForPacmanselfstate:
totalScore
dCapsule
dFood
iflenselfgame.capsulePos:
dCapsule minmanhattanDistanceselfgame.capsulePos, state.pos
iflenselfgame.foodPos:
dFoodminmanhattanDistanceselfgame.foodPos, state.pos
dGhostmanhattanDistanceselfgame.ghostPosstate.pos
# step: define and calculate totalScore for pacman AI agent based on the features of the game.
printtotalScore
return totalScore
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
