Skip to content

Commit

Permalink
fixed: units will flee to the previous square more often
Browse files Browse the repository at this point in the history
(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)
  • Loading branch information
soundmud committed Jan 18, 2024
1 parent be67889 commit 32d0db7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions soundrts/worldentity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions soundrts/worldroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions soundrts/worldunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 32d0db7

Please sign in to comment.