feat: q1 public test pass
This commit is contained in:
parent
5a8f477b21
commit
359e3094ca
@ -75,6 +75,28 @@ class ReflexAgent(Agent):
|
||||
newScaredTimes = [ghostState.scaredTimer for ghostState in newGhostStates]
|
||||
|
||||
"*** YOUR CODE HERE ***"
|
||||
ans = successorGameState.getScore()
|
||||
AVOID_GHOST_SCORE = 10
|
||||
EAT_FOOD_SCORE = 20
|
||||
|
||||
nearest_ghost_distance = 1e9
|
||||
for ghostState in newGhostStates:
|
||||
if ghostState.scaredTimer == 0:
|
||||
nearest_ghost_distance = min(nearest_ghost_distance, util.manhattanDistance(ghostState.getPosition(), newPos)+1)
|
||||
|
||||
nearest_food_distance = 1e9
|
||||
for foodPos in newFood.asList():
|
||||
nearest_food_distance = min(nearest_food_distance, util.manhattanDistance(foodPos, newPos)+1)
|
||||
|
||||
ans -= AVOID_GHOST_SCORE * (1/nearest_ghost_distance)
|
||||
ans += EAT_FOOD_SCORE * (1/nearest_food_distance)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ans
|
||||
|
||||
return successorGameState.getScore()
|
||||
|
||||
def scoreEvaluationFunction(currentGameState: GameState):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user