-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fruit.py
26 lines (17 loc) · 867 Bytes
/
Fruit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
__author__ = "Jason, Evan, Patrick, Christina"
__version__ = 1.0
'''Fruit class - doesn't do much besides sit and decompose.'''
from Organism import Organism
DECAY_RATE = 1
class Fruit(Organism):
def __init__(self, startingEnergy):
'''Creates a new Fruit with the specified amount of energy.'''
self.__type__ = "Fruit"
Organism.__init__(self, startingEnergy, startingEnergy, DECAY_RATE)
def loseEnergy(self):
'''Decreases the fruit's energy by its decay rate, returns the amount of energy lost in case the World needs to refer to it.'''
return Organism.loseEnergy(self)
self.updateEnergy()
def updateEnergy(self):
'''Update's the fruit's smell so that it is proportional to its energy - this will mean that critters will seek out fruit with more energy.'''
self.smell = self.energy