Mercurial > rinkhals
comparison gamelib/animal.py @ 196:edcb5edfa0ff
If the closest chicken is gone, clear it.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 04 Sep 2009 19:27:26 +0000 |
parents | 9d31cfc3afde |
children | 696936621a93 |
comparison
equal
deleted
inserted
replaced
195:9d31cfc3afde | 196:edcb5edfa0ff |
---|---|
282 """Find the path to the closest chicken""" | 282 """Find the path to the closest chicken""" |
283 # Find the closest chicken | 283 # Find the closest chicken |
284 min_dist = 999 | 284 min_dist = 999 |
285 if self.closest not in gameboard.chickens: | 285 if self.closest not in gameboard.chickens: |
286 # Either no target, or someone ate it | 286 # Either no target, or someone ate it |
287 self.closest = None | |
287 for chicken in gameboard.chickens: | 288 for chicken in gameboard.chickens: |
288 dist = chicken.pos.dist(self.pos) | 289 dist = chicken.pos.dist(self.pos) |
289 if chicken.abode: | 290 if chicken.abode: |
290 dist += 10 # Prefer free-ranging chickens | 291 dist += 10 # Prefer free-ranging chickens |
291 if dist < min_dist: | 292 if dist < min_dist: |