From 5a10d66131686fea801ba5b3f266f8abf5a8de18 Mon Sep 17 00:00:00 2001 From: barmal4 Date: Tue, 27 Apr 2021 21:34:05 +0200 Subject: [PATCH] a* impl --- Engine/Game.py | 1 - Engine/PathFinder.py | 13 +++++++------ Engine/__pycache__/Game.cpython-39.pyc | Bin 4049 -> 4021 bytes Engine/__pycache__/PathFinder.cpython-39.pyc | Bin 1669 -> 1693 bytes 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Engine/Game.py b/Engine/Game.py index 4d847334..f611adae 100644 --- a/Engine/Game.py +++ b/Engine/Game.py @@ -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()))) diff --git a/Engine/PathFinder.py b/Engine/PathFinder.py index c55d3322..c701d0cf 100644 --- a/Engine/PathFinder.py +++ b/Engine/PathFinder.py @@ -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 [] diff --git a/Engine/__pycache__/Game.cpython-39.pyc b/Engine/__pycache__/Game.cpython-39.pyc index 07b79109512c55b7f722b396ba1afce0bc1fcd22..c5463636de55a5008aef77b940c7251f2e0ac74d 100644 GIT binary patch delta 301 zcmca8zg3<$k(ZZ?0SNfhIuhD9@>+0&G6H!VKMwk1OwA#Ma~Asw8@J&=QCzccH$~yESS8L%bC$-avi4xCwqEoNkC#rM)71h z?s`U>$@947RqcVgG?|JNfmD$xh){wP${>~okSN=Hn|l?bq$6AgtOhLY02Hg4Jdd|S n9^{ZBI}ic#X^|_4a03w_6N(%rPvjS$9K$Eg$hx_LFOm@e5zIc0 delta 327 zcmdlge^H({k(ZZ?0SJN_CKZ2|j2h7t}ii*q5v0~&%}mWq3mJnMiX?%?Xz~=P0;wV+ zAaRSmAip59BsI549K_>D%gjr0%Fj(I5@VRWio<|$<>dL?(tH=AX?KkreZ?ZR1mfoq2N*2 zvzVMb`#O05#go2)PC78mZ@ytZW~Sb&=l4C&As9d5^QCWn_-B-wpkvxTegR1p$xTIu z3=;}E!J1o&6(FyXY{e9+JyK2cTBQSW?o@P0&Yvb6Cq`aZOn=eFa$WHOE$A(g3OC7c zPVobR#4iHfFm^W7%!evo`Ha+PFCsnCG&&OSzVBd*kmkIW#?ihh#a;R!N;eW&N5s+1 zRXUcXfnCY(vwkK@8~G%SldQA{F-l1&q=zp0*I2KWRydYYB$-}hyRGf&dvL(Tbif3g q+7QsHcfp4>SeU5}EMX0(eq>Wv)qkuDE#2j(u&Lj98&>oufBOec)l`W9 delta 268 zcmWkou}T9$5S^L5J>GJ2g0YFSKtmD-QQ{l7b-W>XZVYjs>bO76?6%<6u)wM8)WL^S>90XMkYSY$>{kij8_0!G2f}ZS|v?xy2&s-KfM~;Qi&?3&c@az8GoocleetxqGWj8 z+gw}y{~Zlh1O|N!$j6vOQ-lqi!$5WhYl0a0(VJkM=k-3eIn@W)