Algorytm_genetyczny #3

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

BIN
images/tłojesień.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

BIN
images/tłowiosna.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

BIN
images/tłozima.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

View File

@ -3,6 +3,7 @@ import pygame
import sys
import sys
sys.path.append('./Animals')
from animals import create_animals, draw_Animals
from agent import Agent
from enclosure import create_enclosures, draw_enclosures, draw_gates
@ -11,6 +12,7 @@ from state_space_search import graphsearch, generate_cost_map
from terrain_obstacle import create_obstacles, draw_Terrain_Obstacles
from constants import Constants, init_pygame
from draw import draw_goal, draw_grid
from season import draw_background, draw_season
const = Constants()
init_pygame(const)
@ -75,7 +77,7 @@ def main():
actions = []
clock = pygame.time.Clock()
spawned = False
season = draw_season()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
@ -83,12 +85,13 @@ def main():
sys.exit()
agent.handle_event(event, const.GRID_WIDTH, const.GRID_HEIGHT, Animals, obstacles)
const.screen.blit(const.background_image, (0, 0))
draw_background(const, season)
draw_grid(const)
draw_enclosures(Enclosures, const)
draw_gates(Enclosures, const)
if not spawned:
spawn_all_animals()
spawn_obstacles()
cost_map = generate_cost_map(Animals, Terrain_Obstacles)

16
season.py Normal file
View File

@ -0,0 +1,16 @@
import pygame
import random
def draw_season():
seasons = ["spring", "summer", "autumn", "winter"]
return random.choice(seasons)
def draw_background(const, season):
season_images = {
"spring": "images/tłowiosna.jpg",
"summer": "images/tło.jpg",
"autumn": "images/tłojesień.jpg",
"winter": "images/tłozima.jpg"
}
background_image = pygame.transform.scale(pygame.image.load(season_images[season]), const.WINDOW_SIZE)
const.screen.blit(background_image, (0, 0))