diff --git a/fitness_plot.png b/fitness_plot.png new file mode 100644 index 0000000..8eae2db Binary files /dev/null and b/fitness_plot.png differ diff --git a/main.py b/main.py index 94294de..ea19bde 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,8 @@ import pygame import sys from gameobjects import * from genetic_alg import GeneticAlgorithm +import matplotlib +matplotlib.use('Agg') # Используем Agg бэкенд для сохранения в файл import matplotlib.pyplot as plt import random @@ -12,7 +14,7 @@ POPULATION_BEST = 0.3 FRAME_RATE = 300 BARRIER_SPEED = 10 BARRIER_DELAY = 100 -MAX_ITERATIONS = -1 +MAX_ITERATIONS = 50 BARRIER_SEED = 42 current_iteration = 1 @@ -40,7 +42,7 @@ last_barrier = None def init_game(): global gameobjects, horses, barriers, upper_bound_rect, lower_bound_rect, spawner, last_barrier, BARRIER_SPEED - random.seed(BARRIER_SEED) + #random.seed(BARRIER_SEED) grass = Background("images/Grass.jpg", 0, 0) grass.set_size(WIDTH, HEIGHT) @@ -94,7 +96,7 @@ while True: plt.xlabel("Iteration") plt.ylabel("Current Fitness") plt.title("Current Fitness per Iteration") - plt.show() + plt.savefig('fitness_plot.png') # Сохраняем график в файл pygame.quit() sys.exit() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e6d11a9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +torch>=2.0.0 +pygame>=2.5.0 +numpy>=1.24.0 +matplotlib>=3.7.0 \ No newline at end of file