changeset 402:3a469d46b820

Tweak safe logic to avoid some corner cases
author Neil Muller <drnlmuller@gmail.com>
date Thu, 19 Nov 2009 11:23:06 +0000
parents 7405f7db469f
children c7cfa230f5d4
files gamelib/animal.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/animal.py	Wed Nov 18 15:54:31 2009 +0000
+++ b/gamelib/animal.py	Thu Nov 19 11:23:06 2009 +0000
@@ -348,10 +348,10 @@
         if self.pos == self.landmarks[-1]:
             if len(self.landmarks) > 1:
                 self.landmarks.pop() # Moving to the next landmark
-            else:
-                # Safely back at the start
-                self.safe = True
-                return self.pos
+        if not gameboard.in_bounds(self.pos) and not self.hunting:
+            # Safely out of sight
+            self.safe = True
+            return self.pos
         return self._find_best_path_step(self.landmarks[-1], gameboard)
 
     def _find_path_to_chicken(self, gameboard):