Mercurial > rinkhals
comparison gamelib/animal.py @ 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 | e5247ec76f24 |
comparison
equal
deleted
inserted
replaced
401:7405f7db469f | 402:3a469d46b820 |
---|---|
346 """Dive back to woodland through the landmarks""" | 346 """Dive back to woodland through the landmarks""" |
347 # find the closest point to our current location in walked path | 347 # find the closest point to our current location in walked path |
348 if self.pos == self.landmarks[-1]: | 348 if self.pos == self.landmarks[-1]: |
349 if len(self.landmarks) > 1: | 349 if len(self.landmarks) > 1: |
350 self.landmarks.pop() # Moving to the next landmark | 350 self.landmarks.pop() # Moving to the next landmark |
351 else: | 351 if not gameboard.in_bounds(self.pos) and not self.hunting: |
352 # Safely back at the start | 352 # Safely out of sight |
353 self.safe = True | 353 self.safe = True |
354 return self.pos | 354 return self.pos |
355 return self._find_best_path_step(self.landmarks[-1], gameboard) | 355 return self._find_best_path_step(self.landmarks[-1], gameboard) |
356 | 356 |
357 def _find_path_to_chicken(self, gameboard): | 357 def _find_path_to_chicken(self, gameboard): |
358 """Find the path to the closest chicken""" | 358 """Find the path to the closest chicken""" |
359 # Find the closest chicken | 359 # Find the closest chicken |