Mercurial > rinkhals
comparison gamelib/animal.py @ 122:d2b19131d537
Don't continue the night if we're not doing anything anymore
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 20:54:47 +0000 |
parents | d539ef5a3333 |
children | 2e3a05b9594d |
comparison
equal
deleted
inserted
replaced
121:7b2660cc7861 | 122:d2b19131d537 |
---|---|
148 Animal.__init__(self, image_left, image_right, pos) | 148 Animal.__init__(self, image_left, image_right, pos) |
149 self.landmarks = [self.pos] | 149 self.landmarks = [self.pos] |
150 self.hunting = True | 150 self.hunting = True |
151 self.dig_pos = None | 151 self.dig_pos = None |
152 self.tick = 0 | 152 self.tick = 0 |
153 self.safe = False | |
153 | 154 |
154 def _cost_tile(self, pos, gameboard): | 155 def _cost_tile(self, pos, gameboard): |
155 if gameboard.in_bounds(pos): | 156 if gameboard.in_bounds(pos): |
156 this_tile = gameboard.tv.get(pos.to_tuple()) | 157 this_tile = gameboard.tv.get(pos.to_tuple()) |
157 cost = self.costs.get(tiles.TILE_MAP[this_tile], 100) | 158 cost = self.costs.get(tiles.TILE_MAP[this_tile], 100) |
213 if self.pos == self.landmarks[-1]: | 214 if self.pos == self.landmarks[-1]: |
214 if len(self.landmarks) > 1: | 215 if len(self.landmarks) > 1: |
215 self.landmarks.pop() # Moving to the next landmark | 216 self.landmarks.pop() # Moving to the next landmark |
216 else: | 217 else: |
217 # Safely back at the start | 218 # Safely back at the start |
219 self.safe = True | |
218 return self.pos | 220 return self.pos |
219 return self._find_best_path_step(self.landmarks[-1], gameboard) | 221 return self._find_best_path_step(self.landmarks[-1], gameboard) |
220 | 222 |
221 def _find_path_to_chicken(self, gameboard): | 223 def _find_path_to_chicken(self, gameboard): |
222 """Find the path to the closest chicken""" | 224 """Find the path to the closest chicken""" |