-
Notifications
You must be signed in to change notification settings - Fork 1
/
animal.py
56 lines (48 loc) · 1.79 KB
/
animal.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class Animal:
def __init__(
self, x, y, worldGrid,
startEnergy,
minEnergyToSurvive,
energyLossRate,
maxDaysToReproduce,
reproductionProbability,
minEnergyToReproduce,
speed,
maxEnergy,
radiusOfVision,
energyLossPercentAfterReproduction,
):
self.x = x
self.y = y
self.worldGrid = worldGrid
self.worldHeight = len(worldGrid)
self.worldWidth = len(worldGrid[0])
self.minEnergyToSurvive = minEnergyToSurvive
self.energyLossRate = energyLossRate
self.energy = startEnergy
self.daysToReproduce = maxDaysToReproduce
self.maxDaysToReproduce = maxDaysToReproduce
self.reproductionProbability = reproductionProbability
self.minEnergyToReproduce = minEnergyToReproduce
self.speed = speed
self.maxEnergy = maxEnergy
self.radiusOfVision = radiusOfVision
self.energyLossPercentAfterReproduction = energyLossPercentAfterReproduction
def checkAlive(self):
return self.energy >= self.minEnergyToSurvive
def updateDailyParameters(self):
if self.daysToReproduce > 0:
self.daysToReproduce -= 1
self.energy -= self.energyLossRate
def getInfo(self):
return [
f'energy: {self.energy}',
f'energyLossRate: {self.energyLossRate}',
f'minEnergyToSurvive: {self.minEnergyToSurvive}',
f'daysToReproduce: {self.daysToReproduce}',
f'speed: {self.speed}',
f'maxEnergy: {self.maxEnergy}',
f'minEnergyToReproduce: {self.minEnergyToReproduce}',
f'reproductionProbability: {self.reproductionProbability}',
f'radiusOfVision: {self.radiusOfVision}',
]