dynamic path change

This commit is contained in:
Vadzim Valchkovich 2023-06-08 13:50:49 +02:00
parent f0cf99cabe
commit d9611b6cd8

View File

@ -71,13 +71,17 @@ class Engine:
if self.paused:
return
self.predict()
if not self.state.path:
if self.goals:
if not self.state.graphsearch(self) and self.goals:
self.objects.remove(self.goals.pop().parent)
self.predict()
else:
if not self.state.path[0].compare_pos(self.goals[-1].position):
self.state.reset()
return
# went path
state = self.user.obj.changeState(self.state.path.pop())
self.clock_increment(state.cost)