feat: add capsule score in evaluation
This commit is contained in:
parent
359e3094ca
commit
05d32500b2
@ -72,12 +72,12 @@ class ReflexAgent(Agent):
|
|||||||
newPos = successorGameState.getPacmanPosition()
|
newPos = successorGameState.getPacmanPosition()
|
||||||
newFood = successorGameState.getFood()
|
newFood = successorGameState.getFood()
|
||||||
newGhostStates = successorGameState.getGhostStates()
|
newGhostStates = successorGameState.getGhostStates()
|
||||||
newScaredTimes = [ghostState.scaredTimer for ghostState in newGhostStates]
|
|
||||||
|
|
||||||
"*** YOUR CODE HERE ***"
|
"*** YOUR CODE HERE ***"
|
||||||
ans = successorGameState.getScore()
|
ans = successorGameState.getScore()
|
||||||
AVOID_GHOST_SCORE = 10
|
AVOID_GHOST_SCORE = 25
|
||||||
EAT_FOOD_SCORE = 20
|
EAT_FOOD_SCORE = 20
|
||||||
|
EAT_CAPSULE_SCORE = 70
|
||||||
|
|
||||||
nearest_ghost_distance = 1e9
|
nearest_ghost_distance = 1e9
|
||||||
for ghostState in newGhostStates:
|
for ghostState in newGhostStates:
|
||||||
@ -88,13 +88,17 @@ class ReflexAgent(Agent):
|
|||||||
for foodPos in newFood.asList():
|
for foodPos in newFood.asList():
|
||||||
nearest_food_distance = min(nearest_food_distance, util.manhattanDistance(foodPos, newPos)+1)
|
nearest_food_distance = min(nearest_food_distance, util.manhattanDistance(foodPos, newPos)+1)
|
||||||
|
|
||||||
|
nearest_capsule_distance = 1e9
|
||||||
|
for capsulePos in successorGameState.getCapsules():
|
||||||
|
nearest_capsule_distance = min(nearest_capsule_distance, util.manhattanDistance(capsulePos, newPos)+1)
|
||||||
|
|
||||||
ans -= AVOID_GHOST_SCORE * (1/nearest_ghost_distance)
|
ans -= AVOID_GHOST_SCORE * (1/nearest_ghost_distance)
|
||||||
ans += EAT_FOOD_SCORE * (1/nearest_food_distance)
|
ans += EAT_FOOD_SCORE * (1/nearest_food_distance)
|
||||||
|
if nearest_capsule_distance != 1e9:
|
||||||
|
ans += EAT_CAPSULE_SCORE * (1/nearest_capsule_distance)
|
||||||
|
else:
|
||||||
|
ans += 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
return successorGameState.getScore()
|
return successorGameState.getScore()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user