Algorytm_genetyczny #3

Merged
s481832 merged 18 commits from Algorytm_genetyczny into master 2024-06-10 13:30:20 +02:00
10 changed files with 19 additions and 20 deletions
Showing only changes of commit 8fcb368258 - Show all commits

View File

@ -43,22 +43,20 @@ def create_animals():
def draw_Animals(Animals, const):
for Animal in Animals:
Animal.draw(const.screen, const.GRID_SIZE)
hunger_level = Animal.getting_hungry(const)
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')
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) >= 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 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)

View File

@ -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:

View File

@ -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":

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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)

BIN
tree.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 KiB