Mercurial > rinkhals
comparison gamelib/animal.py @ 407:bdc8bc78a796
Handle corner case aroudn entering the map
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 06:44:19 +0000 |
parents | f8072b2d6dd1 |
children | bdc4757e0497 |
comparison
equal
deleted
inserted
replaced
406:f8072b2d6dd1 | 407:bdc8bc78a796 |
---|---|
342 if cost < min_cost or (min_cost == cost and dist < min_dist): | 342 if cost < min_cost or (min_cost == cost and dist < min_dist): |
343 # Prefer closest of equal cost points | 343 # Prefer closest of equal cost points |
344 min_dist = dist | 344 min_dist = dist |
345 min_cost = cost | 345 min_cost = cost |
346 best = point | 346 best = point |
347 if min_cost < 20: | 347 if min_cost < 20 or not gameboard.in_bounds(self.pos): |
348 # If we're not on the gameboard yet, there's no point in looking | |
349 # for an optimal path. | |
348 return best | 350 return best |
349 # Else expensive step, so think further | 351 # Else expensive step, so think further |
350 direct_path = self._gen_path(self.pos, final_pos) | 352 direct_path = self._gen_path(self.pos, final_pos) |
351 min_cost = self._cost_path(direct_path, gameboard) | 353 min_cost = self._cost_path(direct_path, gameboard) |
352 min_path = direct_path | 354 min_path = direct_path |