A* polishing

automatically finding coords
This commit is contained in:
Jakub Markil 2024-04-27 23:07:26 +02:00
parent 52ede8588c
commit b38ab2f0bc

View File

@ -214,14 +214,8 @@ class Garbagetruck:
self.modPosiotion(stepX, stepY)
def graphsearch(self):
house_positions = [(15, 5), (17, 5), (19, 5), (21, 5), (15, 8), (17, 8), (19, 8), (21, 8)]
trash_cans = [
{'position': (1, 0), 'type': 'paper'},
{'position': (1, 1), 'type': 'metals_and_plastics'},
{'position': (1, 2), 'type': 'mixed'},
{'position': (1, 3), 'type': 'bio_waste'},
{'position': (1, 4), 'type': 'glass'},
]
house_positions = [house.getPosition() for house in self.houses]
cans_positions = [can.getPosition() for can in self.trashcans]
def succ(elem):
def virtRotateLeft(state):
ort = (state[-1] + 1) % 4
@ -269,7 +263,7 @@ class Garbagetruck:
x, y, _ = state
if (x, y) in house_positions:
return 10
elif any(can['position'] == (x, y) for can in trash_cans):
elif (x,y) in cans_positions:
return 5
else:
return 1