Last active
February 3, 2024 15:25
-
-
Save chuwilliamson/5109f073450d75f2f259fc2e61c2f1ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Run(self): | |
self.Reset() | |
open = self.OPEN | |
closed = self.CLOSED | |
start = self._start | |
goal = self._goal | |
open.append(start) | |
print(open) | |
while open: | |
open.sort(key = lambda x : x.f) | |
current = open[0] | |
open.remove(current) | |
closed.append(current) | |
i = 0 | |
for adj in current.adjacents: | |
if adj.walkable and adj not in closed: | |
if adj not in open: | |
open.append(adj) | |
adj.parent = current | |
adj.g = 10 if i < 4 else 14 | |
else: | |
move = 10 if i < 4 else 14 | |
movecost = move + current.g | |
if movecost < adj.g: | |
adj.parent = current | |
adj.g = movecost | |
i+=1 | |
if goal in open: | |
self.PATH = self.GetPath(goal) | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment