mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
feat(utils, ai): set neat config file location in Config
This commit is contained in:
parent
daadaeb2c6
commit
e6cef45d19
@ -1,13 +0,0 @@
|
||||
import neat
|
||||
from utils import BASE_PATH
|
||||
|
||||
|
||||
def get_config() -> neat.Config:
|
||||
config_path = BASE_PATH / "config.txt"
|
||||
return neat.Config(
|
||||
neat.DefaultGenome,
|
||||
neat.DefaultReproduction,
|
||||
neat.DefaultSpeciesSet,
|
||||
neat.DefaultStagnation,
|
||||
config_path,
|
||||
)
|
||||
10
src/ai/io.py
10
src/ai/io.py
@ -5,6 +5,16 @@ import neat
|
||||
from utils import CONFIG
|
||||
|
||||
|
||||
def get_config() -> neat.Config:
|
||||
return neat.Config(
|
||||
neat.DefaultGenome,
|
||||
neat.DefaultReproduction,
|
||||
neat.DefaultSpeciesSet,
|
||||
neat.DefaultStagnation,
|
||||
CONFIG.ai.config_path,
|
||||
)
|
||||
|
||||
|
||||
def load_genome() -> neat.DefaultGenome:
|
||||
with open(CONFIG.ai.winner_path, "rb") as f:
|
||||
return pickle.load(f)
|
||||
|
||||
@ -5,9 +5,8 @@ import pygame
|
||||
from game import Main
|
||||
from utils import BASE_PATH, CONFIG
|
||||
|
||||
from .config import get_config
|
||||
from .evaluations import eval_genome
|
||||
from .io import save_genome
|
||||
from .io import get_config, save_genome
|
||||
from .log import log
|
||||
from .visualize import plot_progress, plot_species, plot_stats
|
||||
|
||||
|
||||
@ -65,6 +65,7 @@ class AI:
|
||||
winner_path: Path = BASE_PATH / "winner"
|
||||
plot_path: Path = BASE_PATH / "plots"
|
||||
checkpoint_path: Path = BASE_PATH / "checkpoints"
|
||||
config_path: Path = BASE_PATH / "config"
|
||||
|
||||
|
||||
@define
|
||||
|
||||
Loading…
Reference in New Issue
Block a user