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}
|
gscore = {start: 0}
|
||||||
fscore = {start: heurystyka(obiekty, start, cel)}
|
fscore = {start: heurystyka(obiekty, start, cel)}
|
||||||
oheap = []
|
oheap = []
|
||||||
dodatkowy_koszt = 0
|
|
||||||
heapq.heappush(oheap, (fscore[start], start))
|
heapq.heappush(oheap, (fscore[start], start))
|
||||||
while oheap:
|
while oheap:
|
||||||
current = heapq.heappop(oheap)[1]
|
current = heapq.heappop(oheap)[1]
|
||||||
if current == cel:
|
if current == cel:
|
||||||
#obiekty["plansza"][current[0], current[1]].setKolor((255, 0, 0))
|
|
||||||
data = []
|
data = []
|
||||||
while current in came_from:
|
while current in came_from:
|
||||||
|
|
||||||
@ -34,7 +32,6 @@ def astar(obiekty, start, cel):
|
|||||||
current = came_from[current]
|
current = came_from[current]
|
||||||
return data[::-1]
|
return data[::-1]
|
||||||
close_set.add(current)
|
close_set.add(current)
|
||||||
#obiekty["plansza"][current[0], current[1]].setKolor((255, 0, 0))
|
|
||||||
for i, j in sasiedzi:
|
for i, j in sasiedzi:
|
||||||
sasiad = current[0] + i, current[1] + j
|
sasiad = current[0] + i, current[1] + j
|
||||||
|
|
||||||
@ -54,5 +51,4 @@ def astar(obiekty, start, cel):
|
|||||||
fscore[sasiad] = tentative_h_score + gscore[current]
|
fscore[sasiad] = tentative_h_score + gscore[current]
|
||||||
gscore[sasiad] = gscore[current] + heurystyka(obiekty, current, sasiad)
|
gscore[sasiad] = gscore[current] + heurystyka(obiekty, current, sasiad)
|
||||||
heapq.heappush(oheap, (fscore[sasiad], sasiad))
|
heapq.heappush(oheap, (fscore[sasiad], sasiad))
|
||||||
#obiekty["plansza"][sasiad[0], sasiad[1]].setKolor((0, 255, 0))
|
|
||||||
return False
|
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)
|
obiekty["smieciarka"].astar_move(obiekty, (obiekty["smieciarka"].x, obiekty["smieciarka"].y), cel)
|
||||||
|
|
||||||
clock.tick(7)
|
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()
|
pygame.quit()
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ class Smieciarka(pygame.sprite.Sprite):
|
|||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
self.pozycja = (self.x, self.y)
|
|
||||||
self.image = pygame.image.load('resources/plansza/smieciarka.png')
|
self.image = pygame.image.load('resources/plansza/smieciarka.png')
|
||||||
self.obraz = None
|
self.obraz = None
|
||||||
self.ruch = 1
|
self.ruch = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user