unsresolved merge

This commit is contained in:
Bowske 2020-04-26 14:11:19 +02:00
commit e2facd2c42
2 changed files with 15 additions and 12 deletions

View File

@ -42,15 +42,17 @@ def astar(obiekty, start, cel):
continue continue
elif 6 <= sasiad[0] <= 7 and 10 <= sasiad[1] <= 11: elif 6 <= sasiad[0] <= 7 and 10 <= sasiad[1] <= 11:
continue continue
tentative_h_score = heurystyka(obiekty, sasiad, cel) + heurystyka(obiekty, current, sasiad) tentative_g_score = gscore[current] + \
heurystyka(obiekty, current, sasiad)
if sasiad in [i[1] for i in oheap] and tentative_h_score > hscore.get(current, 0): if sasiad in close_set and tentative_g_score >= gscore.get(sasiad, 0):
continue continue
if sasiad not in close_set and sasiad not in [i[1] for i in oheap]: if sasiad not in close_set and sasiad not in [i[1] for i in oheap]:
came_from[sasiad] = current came_from[sasiad] = current
hscore[sasiad] = tentative_h_score hscore[sasiad] = tentative_h_score
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)) obiekty["plansza"][sasiad[0], sasiad[1]].setKolor((0, 255, 0))
return False return False

View File

@ -54,15 +54,16 @@ class Smieciarka(pygame.sprite.Sprite):
sciezka = astar.astar(obiekty, self.pozycja, sciezka = astar.astar(obiekty, self.pozycja,
(random.randrange(15), random.randrange(15))) (random.randrange(15), random.randrange(15)))
print(sciezka) print(sciezka)
for koord in sciezka: if sciezka:
if koord[0] == self.x - 1 and koord[1] == self.y: for koord in sciezka:
self.w_lewo() if koord[0] == self.x - 1 and koord[1] == self.y:
elif koord[0] == self.x + 1 and koord[1] == self.y: self.w_lewo()
self.w_prawo() elif koord[0] == self.x + 1 and koord[1] == self.y:
elif koord[0] == self.x and koord[1] + 1 == self.y: self.w_prawo()
self.w_gore() elif koord[0] == self.x and koord[1] + 1 == self.y:
elif koord[0] == self.x and koord[1] - 1 == self.y: self.w_gore()
self.w_dol() elif koord[0] == self.x and koord[1] - 1 == self.y:
self.w_dol()
print("skonczylem") print("skonczylem")
def w_lewo(self): def w_lewo(self):