Algorytm_genetyczny #3
@ -43,22 +43,20 @@ def create_animals():
|
||||
|
||||
def draw_Animals(Animals, const):
|
||||
for Animal in Animals:
|
||||
|
||||
Animal.draw(const.screen, const.GRID_SIZE)
|
||||
|
||||
if Animal.getting_hungry(const) == 10:
|
||||
Animal.draw_exclamation(const.screen, const.GRID_SIZE, Animal.x, Animal.y)
|
||||
Animal.draw_food(const.screen,const.GRID_SIZE,Animal.x,Animal.y,'images/empty_bowl.png')
|
||||
hunger_level = Animal.getting_hungry(const)
|
||||
|
||||
if Animal.getting_hungry(const) >= 8 and Animal.getting_hungry(const) < 5:
|
||||
Animal.draw_exclamation(const.screen, const.GRID_SIZE, Animal.x, Animal.y)
|
||||
Animal.draw_food(const.screen,const.GRID_SIZE,Animal.x,Animal.y,'images/almost_empty.png')
|
||||
if hunger_level >= 9:
|
||||
food_image = 'images/empty_bowl.png'
|
||||
elif hunger_level >= 8:
|
||||
food_image = 'images/almost_empty.png'
|
||||
elif hunger_level >= 5:
|
||||
food_image = 'images/half_bowl.png'
|
||||
else:
|
||||
food_image = 'images/full_bowl.png'
|
||||
|
||||
if Animal.getting_hungry(const) >= 5 and Animal.getting_hungry(const) < 4:
|
||||
Animal.draw_food(const.screen,const.GRID_SIZE,Animal.x,Animal.y,'images/half_bowl.png')
|
||||
|
||||
if Animal.getting_hungry(const) < 5:
|
||||
Animal.draw_food(const.screen,const.GRID_SIZE,Animal.x,Animal.y,'images/full_bowl.png')
|
||||
Animal.draw_food(const.screen, const.GRID_SIZE, Animal.x, Animal.y, food_image)
|
||||
|
||||
if Animal.ill:
|
||||
Animal.draw_illness(const.screen, const.GRID_SIZE, Animal.x, Animal.y)
|
@ -16,7 +16,7 @@ class Bat(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 30
|
||||
minutes_passed = delta.total_seconds() / 30*5
|
||||
self._starttime = checktime
|
||||
|
||||
if const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -18,7 +18,7 @@ class Bear(Animal):
|
||||
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 60
|
||||
minutes_passed = delta.total_seconds() / 60*5
|
||||
self._starttime = checktime
|
||||
|
||||
if const.IS_NIGHT and self._feed < 10 and const.season != "winter":
|
||||
|
@ -22,7 +22,7 @@ class Elephant(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 50
|
||||
minutes_passed = delta.total_seconds() / 50*5
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -17,7 +17,7 @@ class Giraffe(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 30
|
||||
minutes_passed = delta.total_seconds() / 30*5
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -16,7 +16,7 @@ class Owl(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 25
|
||||
minutes_passed = delta.total_seconds() / 25*5
|
||||
self._starttime = checktime
|
||||
|
||||
if const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -17,7 +17,7 @@ class Parrot(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 20
|
||||
minutes_passed = delta.total_seconds() / 20*5
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -17,7 +17,7 @@ class Penguin(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 15
|
||||
minutes_passed = delta.total_seconds() / 15*5
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
1
main.py
1
main.py
@ -101,6 +101,7 @@ def main():
|
||||
cost_map = generate_cost_map(Animals, Terrain_Obstacles)
|
||||
for animal in Animals:
|
||||
animal._feed = 0
|
||||
# animal._feed = random.randint(0, 10)
|
||||
spawned = True
|
||||
|
||||
draw_Animals(Animals, const)
|
||||
|
Loading…
Reference in New Issue
Block a user