tracking q8
This commit is contained in:
@ -149,5 +149,26 @@ class GreedyBustersAgent(BustersAgent):
|
|||||||
[beliefs for i, beliefs in enumerate(self.ghostBeliefs)
|
[beliefs for i, beliefs in enumerate(self.ghostBeliefs)
|
||||||
if livingGhosts[i+1]]
|
if livingGhosts[i+1]]
|
||||||
"*** YOUR CODE HERE ***"
|
"*** YOUR CODE HERE ***"
|
||||||
raiseNotDefined()
|
# Find the most likely position of each ghost
|
||||||
|
ghostPositions = []
|
||||||
|
for beliefs in livingGhostPositionDistributions:
|
||||||
|
ghostPositions.append(beliefs.argMax())
|
||||||
|
# Find the closest ghost
|
||||||
|
closestGhost = None
|
||||||
|
closestDistance = float('inf')
|
||||||
|
for ghost in ghostPositions:
|
||||||
|
distance = self.distancer.getDistance(pacmanPosition, ghost)
|
||||||
|
if distance < closestDistance:
|
||||||
|
closestDistance = distance
|
||||||
|
closestGhost = ghost
|
||||||
|
# Find the closest action to the closest ghost
|
||||||
|
closestAction = None
|
||||||
|
closestDistance = float('inf')
|
||||||
|
for action in legal:
|
||||||
|
successorPosition = Actions.getSuccessor(pacmanPosition, action)
|
||||||
|
distance = self.distancer.getDistance(successorPosition, closestGhost)
|
||||||
|
if distance < closestDistance:
|
||||||
|
closestDistance = distance
|
||||||
|
closestAction = action
|
||||||
|
return closestAction
|
||||||
"*** END YOUR CODE HERE ***"
|
"*** END YOUR CODE HERE ***"
|
||||||
|
Reference in New Issue
Block a user