[Edu-sig] Life Clock
Andre Roberge
andre.roberge at gmail.com
Sat Apr 22 05:15:45 CEST 2006
On 4/21/06, kirby urner <kirby.urner at gmail.com> wrote:
> Here's some working code except there's something not yet right -- no
> fox is eating a bunny yet. I haven't figured out why.
>
[snip]
> class Fox (Mammal):
>
# add the following (I think :-)
def update(self):
Mammal.update(self)
self.eat()
> def eat(self):
> for bunny in self.eco.bunnies.values():
> if (self.xpos == bunny.xpos) and (self.ypos == bunny.ypos):
> self.stomach.append( bunny )
> bunny.iseaten(self)
>
> def die(self):
> print '%s dies of old age.' % self
>
> def __repr__(self):
> return 'Fox %s age: %s @ (%s, %s)' % (self.name, self.clock,
> self.xpos, self.ypos)
>
[snip]
André
More information about the Edu-sig
mailing list