reprezentacja_wiedzy2 #1

Merged
s481852 merged 7 commits from reprezentacja_wiedzy2 into master 2024-03-24 19:38:01 +01:00
22 changed files with 131 additions and 10 deletions
Showing only changes of commit 8508ac9b53 - Show all commits

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,7 +7,7 @@ class Animal:
self.y = y - 1
self.image = image
self.adult = adult
self._feed = 0 #nowe zierze jest głodne
self._feed = 0 #nowe zwierze jest głodne
def draw(self, screen, grid_size):
self.image = pygame.transform.scale(self.image, (grid_size, grid_size))

29
bear.py Normal file
View File

@ -0,0 +1,29 @@
from animal import Animal
import pygame
from datetime import datetime
class Bear(Animal):
def __init__(self, x, y, adult=False):
Bear_image = pygame.image.load('images/bear.png')
super().__init__(x, y, Bear_image, adult)
self.food_type = "fish"
self._starttime = datetime.now()
def feed(self):
self.getting_hungry()
if self._feed < 5:
return 'False'
else:
return 'True'
def getting_hungry(self):
checktime = datetime.now()
delta = checktime - self._starttime
minutes_passed = delta.total_seconds() / 60
self._feed += minutes_passed
self._starttime = checktime

View File

@ -6,7 +6,7 @@ from datetime import datetime
class Elephant(Animal):
def __init__(self, x, y, adult=False):
Elephant_image = pygame.image.load('elephant.png')
Elephant_image = pygame.image.load('images/elephant.png')
super().__init__(x, y, Elephant_image, adult)
self.food_type = "leaves"
self._starttime = datetime.now()

29
giraffe.py Normal file
View File

@ -0,0 +1,29 @@
from animal import Animal
import pygame
from datetime import datetime
class Giraffe(Animal):
def __init__(self, x, y, adult=False):
Giraffe_image = pygame.image.load('images/giraffe.png')
super().__init__(x, y, Giraffe_image, adult)
self.food_type = "leaves"
self._starttime = datetime.now()
def feed(self):
self.getting_hungry()
if self._feed < 3:
return 'False'
else:
return 'True'
def getting_hungry(self):
checktime = datetime.now()
delta = checktime - self._starttime
minutes_passed = delta.total_seconds() / 60
self._feed += minutes_passed
self._starttime = checktime

View File

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 248 KiB

BIN
images/bear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

Before

Width:  |  Height:  |  Size: 642 KiB

After

Width:  |  Height:  |  Size: 642 KiB

View File

After

Width:  |  Height:  |  Size: 63 KiB

BIN
images/giraffe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

BIN
images/parrot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
images/penguin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 209 KiB

21
main.py
View File

@ -1,11 +1,15 @@
import pygame
import sys
from elephant import Elephant
from giraffe import Giraffe
from penguin import Penguin
from parrot import Parrot
from bear import Bear
from agent import Agent
BLACK = (0, 0, 0)
GRID_SIZE = 75
GRID_SIZE = 50
GRID_WIDTH = 20
GRID_HEIGHT = 10
@ -17,18 +21,19 @@ pygame.display.set_caption("Mini Zoo")
background_image = pygame.image.load('tło.jpg')
background_image = pygame.image.load('images/tło.jpg')
background_image = pygame.transform.scale(background_image, WINDOW_SIZE)
exclamation_image = pygame.image.load('exclamation.png')
exclamation_image = pygame.image.load('images/exclamation.png')
exclamation_image = pygame.transform.scale(exclamation_image, (GRID_SIZE,GRID_SIZE))
an1 = Elephant(10, 2)
an2 = Elephant(12, 2)
an3 = Elephant(14, 7)
an1 = Parrot(10, 2)
an2 = Penguin(12, 2)
an3 = Bear(14, 10)
old_an2 = Giraffe(18,4, adult=True)
old_an1 = Elephant(3, 6, adult=True)
Animals = [an1, an2, an3,old_an1]
Animals = [an1, an2, an3, old_an1, old_an2]
def draw_grid():
for y in range(0, GRID_HEIGHT * GRID_SIZE, GRID_SIZE):
@ -48,7 +53,7 @@ def draw_Animals():
def main():
agent = Agent(0, 0, 'avatar.png', GRID_SIZE)
agent = Agent(0, 0, 'images/avatar.png', GRID_SIZE)
clock = pygame.time.Clock()
while True:

29
parrot.py Normal file
View File

@ -0,0 +1,29 @@
from animal import Animal
import pygame
from datetime import datetime
class Parrot(Animal):
def __init__(self, x, y, adult=False):
Parrot_image = pygame.image.load('images/parrot.png')
super().__init__(x, y, Parrot_image, adult)
self.food_type = "grain"
self._starttime = datetime.now()
def feed(self):
self.getting_hungry()
if self._feed < 3:
return 'False'
else:
return 'True'
def getting_hungry(self):
checktime = datetime.now()
delta = checktime - self._starttime
minutes_passed = delta.total_seconds() / 60
self._feed += minutes_passed
self._starttime = checktime

29
penguin.py Normal file
View File

@ -0,0 +1,29 @@
from animal import Animal
import pygame
from datetime import datetime
class Penguin(Animal):
def __init__(self, x, y, adult=False):
Penguin_image = pygame.image.load('images/penguin.png')
super().__init__(x, y, Penguin_image, adult)
self.food_type = "fish"
self._starttime = datetime.now()
def feed(self):
self.getting_hungry()
if self._feed < 2:
return 'False'
else:
return 'True'
def getting_hungry(self):
checktime = datetime.now()
delta = checktime - self._starttime
minutes_passed = delta.total_seconds() / 60
self._feed += minutes_passed
self._starttime = checktime