Mercurial > rinkhals
changeset 32:f5f74f1f3a0b
Discourage foxes from stepping on each other
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 18:59:12 +0000 |
parents | 3c4db7bba432 |
children | c8436f1752d7 |
files | gamelib/animal.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/animal.py Sun Aug 30 18:56:09 2009 +0000 +++ b/gamelib/animal.py Sun Aug 30 18:59:12 2009 +0000 @@ -75,6 +75,15 @@ if closest.pos == self.pos: gameboard.remove_chicken(closest) self.full = True + for fox in gameboard.foxes: + if fox is not self: + if fox.pos[0] == xpos and fox.pos[1] == ypos: + if xpos != self.pos[0]: + xpos = self.pos[0] + elif ypos != self.pos[1]: + ypos = self.pos[1] + else: # We move a step away + xpos += 1 self.pos = (xpos, ypos)