Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-03-28 16:05:08 +01:00
parent 02202e4d3d
commit b60ffd87aa
108 changed files with 74710 additions and 15 deletions
+3 -3
View File
@@ -44,7 +44,7 @@ class Rat(Unit):
nx, ny = x + dx, y + dy
if not self.game.map.in_bounds(nx, ny):
continue
if self.game.map.is_empty(nx, ny) and (nx, ny) != self.position_before:
if self.game.map.is_traversable(nx, ny) and (nx, ny) != self.position_before:
neighbors.append((nx, ny))
if not neighbors:
@@ -52,11 +52,11 @@ class Rat(Unit):
nx, ny = x + dx, y + dy
if not self.game.map.in_bounds(nx, ny):
continue
if self.game.map.is_empty(nx, ny):
if self.game.map.is_traversable(nx, ny):
neighbors.append((nx, ny))
if not neighbors:
print(f"[flow] rat fallback: no empty neighbors from position={self.position}", flush=True)
print(f"[flow] rat fallback: no traversable neighbors from position={self.position}", flush=True)
return self.position
self.position_before = self.position