Poprawione wyświetlanie jedzenia i wykrzykników
25
animal.py
@ -1,7 +1,6 @@
|
||||
import pygame
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class Animal:
|
||||
def __init__(self, x, y,name, image, food_image, food, environment, adult=False,):
|
||||
self.x = x - 1
|
||||
@ -15,29 +14,31 @@ class Animal:
|
||||
self.environment = environment #hot/cold/medium
|
||||
|
||||
def draw(self, screen, grid_size):
|
||||
self.image = pygame.transform.scale(self.image, (grid_size, grid_size))
|
||||
if self.adult:
|
||||
# If adult, draw like AdultAnimal
|
||||
# Jeśli zwierzę jest dorosłe, skaluj obrazek na większy rozmiar
|
||||
new_width = grid_size * 2
|
||||
new_height = grid_size * 2
|
||||
scaled_image = pygame.transform.scale(self.image, (new_width, new_height))
|
||||
screen.blit(scaled_image, (self.x * grid_size, self.y * grid_size))
|
||||
else:
|
||||
# If not adult, draw like normal Animal
|
||||
screen.blit(self.image, (self.x * grid_size, self.y * grid_size))
|
||||
# Jeśli zwierzę nie jest dorosłe, skaluj obrazek na rozmiar jednej kratki
|
||||
scaled_image = pygame.transform.scale(self.image, (grid_size, grid_size))
|
||||
screen.blit(scaled_image, (self.x * grid_size, self.y * grid_size))
|
||||
|
||||
def draw_exclamation(self, screen, grid_size, x, y):
|
||||
exclamation_image = pygame.image.load('images/exclamation.png')
|
||||
exclamation_image = pygame.transform.scale(exclamation_image, (grid_size,grid_size))
|
||||
screen.blit(exclamation_image, (x*grid_size, y*grid_size - grid_size))
|
||||
exclamation_image = pygame.transform.scale(exclamation_image, (int(grid_size * 0.45), int(grid_size * 0.45)))
|
||||
screen.blit(exclamation_image, (x * grid_size, y * grid_size))
|
||||
|
||||
def draw_food(self, screen, grid_size, x, y):
|
||||
scale = 0.45
|
||||
food_image = pygame.image.load(self.food_image)
|
||||
food_image = pygame.transform.scale(food_image, (grid_size,grid_size))
|
||||
screen.blit(food_image, (x*grid_size, y*grid_size + grid_size))
|
||||
|
||||
|
||||
|
||||
if(self.adult):
|
||||
y = y + 1
|
||||
scale = 0.7
|
||||
food_image = pygame.transform.scale(food_image, (int(grid_size * scale), int(grid_size * scale)))
|
||||
screen.blit(food_image, (x * grid_size, (y + 1) * grid_size - int(grid_size * scale)))
|
||||
|
||||
@abstractmethod
|
||||
def feed(self):
|
||||
@ -45,4 +46,4 @@ class Animal:
|
||||
|
||||
@abstractmethod
|
||||
def getting_hungry(self):
|
||||
pass
|
||||
pass
|
Before Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 248 KiB |
BIN
images/bear.png
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 2.3 MiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 64 KiB |
BIN
images/fish.png
Before Width: | Height: | Size: 934 KiB After Width: | Height: | Size: 601 KiB |
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 444 KiB |
BIN
images/meat.png
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 232 KiB |
BIN
images/milk.png
Before Width: | Height: | Size: 288 KiB After Width: | Height: | Size: 460 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 2.4 MiB |
7
main.py
@ -13,7 +13,7 @@ from state_space_search import graphsearch
|
||||
|
||||
BLACK = (0, 0, 0)
|
||||
|
||||
GRID_SIZE = 50
|
||||
GRID_SIZE = 64
|
||||
GRID_WIDTH = 30
|
||||
GRID_HEIGHT = 15
|
||||
|
||||
@ -177,9 +177,10 @@ def main():
|
||||
spawn_all_animals()
|
||||
|
||||
# region Test szukania ścieżki
|
||||
for animal in Animals:
|
||||
animal._feed = 2 # Ustawienie aby zwierzę było głodne
|
||||
animal = random.choice(Animals)
|
||||
actions = graphsearch(agent.istate, (animal.x, animal.y), GRID_WIDTH, GRID_HEIGHT, obstacles)
|
||||
animal._feed = 2 # Ustawienie aby zwierzę było głodne
|
||||
# actions = graphsearch(agent.istate, (animal.x, animal.y), GRID_WIDTH, GRID_HEIGHT, obstacles)
|
||||
# endregion
|
||||
|
||||
spawned = True
|
||||
|