From 32d0db7772fc8c5d2a5304ab3cc62c89c258a073 Mon Sep 17 00:00:00 2001 From: soundmud Date: Thu, 18 Jan 2024 19:46:11 +0100 Subject: [PATCH] fixed: units will flee to the previous square more often (2 bugs: unit._previous_square was incorrectly updated after movement; and the fleeing unit was considering more candidates even after finding an acceptable one, potentially ignoring unit._previous_square) --- soundrts/worldentity.py | 1 + soundrts/worldroom.py | 4 ---- soundrts/worldunit.py | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/soundrts/worldentity.py b/soundrts/worldentity.py index 8bdbb1ca..5606e902 100644 --- a/soundrts/worldentity.py +++ b/soundrts/worldentity.py @@ -103,6 +103,7 @@ def _move_to_new_place(self, new_place): self.place.leave(self) if not new_place: self.place.world.unregister_entity(self) + self._previous_square = self.place self.place = new_place if new_place: new_place.enter(self) diff --git a/soundrts/worldroom.py b/soundrts/worldroom.py index 83b9b54e..b7847cc3 100644 --- a/soundrts/worldroom.py +++ b/soundrts/worldroom.py @@ -168,10 +168,6 @@ def __getstate__(self): del d["spiral"] return d - def enter(self, o): - super().enter(o) - o._previous_square = self - def is_near(self, square): # FIXME: not used (remove?) try: return (abs(self.col - square.col), abs(self.row - square.row)) in ( diff --git a/soundrts/worldunit.py b/soundrts/worldunit.py index 7b2c41c0..5d6401c3 100644 --- a/soundrts/worldunit.py +++ b/soundrts/worldunit.py @@ -677,6 +677,7 @@ def flee(self): ): self.notify("flee") self.take_order(["go", s.id], imperative=True) + break def decide(self): if self.is_inside: