From d9611b6cd837686504d56841ea5b20bddbf18b97 Mon Sep 17 00:00:00 2001 From: Vadzim Valchkovich Date: Thu, 8 Jun 2023 13:50:49 +0200 Subject: [PATCH] dynamic path change --- src/Engine.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Engine.py b/src/Engine.py index d57a9be..5230cb0 100644 --- a/src/Engine.py +++ b/src/Engine.py @@ -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)