-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnimalClasses.py
134 lines (98 loc) · 3.45 KB
/
AnimalClasses.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#
# AnimalClasses.py - Contains the Classes for our animals
#
from Animal import *
tinder4wombats = []
womSpeed = 1
womHunger = 1
tinder4emus = []
emuSpeed = 2
emuHunger = 1
tinder4possums = []
possSpeed = 1
possHunger = 2
tinder4kangaroos = []
kangSpeed = 3
kangHunger = 3
tinder4foxes = []
foxSpeed = 2
foxHunger = 1
class wombat(animal):
def __init__(self, home, xdim, ydim, baseArea, fps):
super().__init__("wombat", home, xdim, ydim, baseArea, fps, womSpeed, womHunger)
tinder4wombats.append((0,0))
@lru_cache(maxsize=3)
def periodic(self, form):
super().periodic(form, tinder4wombats)
return(self.posn)
def death(self):
self.isDead = self.isDead + random.randint(0,3)
if self.isDead > 1000:
return(True)
def canBreed(self):
if self.mating and self.cantMate == False:
return(True)
class emu(animal):
def __init__(self, home, xdim, ydim, baseArea, fps):
super().__init__("emu", home, xdim, ydim, baseArea, fps, emuSpeed, emuHunger)
tinder4emus.append((0,0))
@lru_cache(maxsize=3)
def periodic(self, form):
super().periodic(form, tinder4emus)
return(self.posn)
def death(self):
self.isDead = self.isDead + random.randint(0,3)
if self.isDead > 1000:
return(True)
def canBreed(self):
if self.mating and self.cantMate == False:
return(True)
class possum(animal):
def __init__(self, home, xdim, ydim, baseArea, fps):
super().__init__("possum", home, xdim, ydim, baseArea, fps, possSpeed, possHunger)
tinder4possums.append((0,0))
@lru_cache(maxsize=3)
def periodic(self, form):
super().periodic(form, tinder4possums)
return(self.posn)
def death(self):
self.isDead = self.isDead + random.randint(0,3)
if self.isDead > 1400:
return(True)
def canBreed(self):
if self.mating and self.cantMate == False:
return(True)
class kangaroo(animal):
def __init__(self, home, xdim, ydim, baseArea, fps):
super().__init__("wombat", home, xdim, ydim, baseArea, fps, kangSpeed, kangHunger)
tinder4kangaroos.append((0,0))
@lru_cache(maxsize=3)
def periodic(self, form):
super().periodic(form, tinder4kangaroos)
return(self.posn)
def death(self):
self.isDead = self.isDead + random.randint(0,3)
if self.isDead > 1000:
return(True)
def canBreed(self):
if self.mating and self.cantMate == False:
return(True)
class fox(animal):
def __init__(self, home, xdim, ydim, baseArea, fps):
super().__init__("fox", home, xdim, ydim, baseArea, fps, foxSpeed, foxHunger)
tinder4foxes.append((0,0))
self.matingCooldown = 500
def sniff(self, ani):
if math.sqrt((abs(ani[0])-abs(self.posn[0]))**2 + (abs(ani[1])-abs(self.posn[1]))**2) <= math.sqrt((abs(self.foodCood[0])-abs(self.posn[0]))**2 + (abs(self.foodCood[1])-abs(self.posn[1]))**2):
self.foodCood = [ani[0],ani[1]]
@lru_cache(maxsize=3)
def periodic(self, form):
super().periodic(form, tinder4foxes)
return(self.posn)
def death(self):
self.isDead = self.isDead + random.randint(0,3)
if self.isDead > 1200:
return(True)
def canBreed(self):
if self.mating and self.cantMate == False:
return(True)