Mercurial > rinkhals
comparison gamelib/animal.py @ 257:fcaae2cfe3cd
Make foxes less determistic when avoiding other foxes
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 13:00:09 +0000 |
parents | 844bfb23d4b6 |
children | 445f746449fa |
comparison
equal
deleted
inserted
replaced
256:bca2f4396de8 | 257:fcaae2cfe3cd |
---|---|
393 for poss in moves: | 393 for poss in moves: |
394 cost = self._cost_tile(poss, gameboard) | 394 cost = self._cost_tile(poss, gameboard) |
395 if cost < min_cost: | 395 if cost < min_cost: |
396 min_cost = cost | 396 min_cost = cost |
397 final_pos = poss | 397 final_pos = poss |
398 if cost == min_cost and random.randint(0, 1) > 0: | |
399 # Add some randomness in this case | |
400 final_pos = poss | |
398 if not final_pos: | 401 if not final_pos: |
399 # No good choice, so stay put | 402 # No good choice, so stay put |
400 return self.pos | 403 return self.pos |
401 if gameboard.in_bounds(final_pos): | 404 if gameboard.in_bounds(final_pos): |
402 this_tile = gameboard.tv.get(final_pos.to_tuple()) | 405 this_tile = gameboard.tv.get(final_pos.to_tuple()) |