a* impl
This commit is contained in:
parent
a4c1164962
commit
5a10d66131
@ -96,7 +96,6 @@ class Game:
|
||||
|
||||
def findBomb(self):
|
||||
# return BfsPathFinder(self.board).findBomb(State(self.agent.getOrientation(),Point(self.agent.getPoint().getX(),self.agent.getPoint().getY())))
|
||||
point = self.board.bombMap.popitem()
|
||||
return PathFinder(self.board).findBomb(State(self.agent.getOrientation(),Point(self.agent.getPoint().getX(),self.agent.getPoint().getY())))
|
||||
|
||||
|
||||
|
@ -23,21 +23,22 @@ class PathFinder(BfsPathFinder):
|
||||
cameFrom = dict()
|
||||
cameFrom[x] = None
|
||||
|
||||
while not self.openList:
|
||||
while self.openList:
|
||||
current = self.minKey(self.fScore, self.openList)
|
||||
|
||||
if self.checkGoal(current):
|
||||
return self.constructActions(current, startState)
|
||||
|
||||
self.openList.remove(current)
|
||||
for next in self.getNeighbour(current):
|
||||
tentativeGScore = self.gScore.get(self.current) + current.state.getPoint().distance(next.state.getPoint())
|
||||
tentativeGScore = self.gScore.get(current) + current.state.getPoint().distance(next.state.getPoint())
|
||||
if tentativeGScore < self.gScore.get(next, 10000):
|
||||
cameFrom[next] = current
|
||||
self.cameFrom[next] = current
|
||||
next.parent = current
|
||||
self.gScore[next] = tentativeGScore
|
||||
self.fScore[next] = next.state.getPoint().distance(startState.getPoint())
|
||||
if next not in self.openList:
|
||||
self.openList.append(next)
|
||||
if next not in self.openList:
|
||||
self.openList.append(next)
|
||||
|
||||
return []
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user