lekkie oczyszczenie
This commit is contained in:
parent
090eb268e6
commit
69d8d74d26
4
astar.py
4
astar.py
@ -21,12 +21,10 @@ def astar(obiekty, start, cel):
|
||||
gscore = {start: 0}
|
||||
fscore = {start: heurystyka(obiekty, start, cel)}
|
||||
oheap = []
|
||||
dodatkowy_koszt = 0
|
||||
heapq.heappush(oheap, (fscore[start], start))
|
||||
while oheap:
|
||||
current = heapq.heappop(oheap)[1]
|
||||
if current == cel:
|
||||
#obiekty["plansza"][current[0], current[1]].setKolor((255, 0, 0))
|
||||
data = []
|
||||
while current in came_from:
|
||||
|
||||
@ -34,7 +32,6 @@ def astar(obiekty, start, cel):
|
||||
current = came_from[current]
|
||||
return data[::-1]
|
||||
close_set.add(current)
|
||||
#obiekty["plansza"][current[0], current[1]].setKolor((255, 0, 0))
|
||||
for i, j in sasiedzi:
|
||||
sasiad = current[0] + i, current[1] + j
|
||||
|
||||
@ -54,5 +51,4 @@ def astar(obiekty, start, cel):
|
||||
fscore[sasiad] = tentative_h_score + gscore[current]
|
||||
gscore[sasiad] = gscore[current] + heurystyka(obiekty, current, sasiad)
|
||||
heapq.heappush(oheap, (fscore[sasiad], sasiad))
|
||||
#obiekty["plansza"][sasiad[0], sasiad[1]].setKolor((0, 255, 0))
|
||||
return False
|
||||
|
4
game.py
4
game.py
@ -89,11 +89,7 @@ def game():
|
||||
obiekty["smieciarka"].astar_move(obiekty, (obiekty["smieciarka"].x, obiekty["smieciarka"].y), cel)
|
||||
|
||||
clock.tick(7)
|
||||
#start = obiekty["plansza"][0, 14]
|
||||
#koniec = obiekty["plansza"][14, 0]
|
||||
|
||||
#print(astar.astar(obiekty, (0, 14), (14, 0)))
|
||||
#print(len(astar.astar(start, koniec)))
|
||||
pygame.quit()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user