-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
129 lines (110 loc) · 6.51 KB
/
config.py
File metadata and controls
129 lines (110 loc) · 6.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# ──────────────────────────────────────────────────────────
# Project : Snake_AI
# File : config.py
# Author : ProGen18
# Created : 25-02-2026
# Modified : 27-03-2026
# Purpose : Store all configuration parameters for training and UI
# ──────────────────────────────────────────────────────────
# ============================================================
# IMPORTS
# ============================================================
from dataclasses import dataclass
# ============================================================
# CONFIGURATION
# ============================================================
# ╔══════════════════════════════════════════════════════════╗
# ║ ConfigEntrainement ║
# ╠══════════════════════════════════════════════════════════╣
# ║ Handles: ║
# ║ • Training hyperparameters ║
# ║ • Environment dimensions and limits ║
# ║ • Neural network architecture sizing ║
# ╚══════════════════════════════════════════════════════════╝
@dataclass
class ConfigEntrainement:
"""
Configuration for the Snake AI training environment and model properties.
Attributes:
graine (int): Random seed for reproducibility.
nb_environnements (int): Number of parallel environments.
largeur (int): Width of the game area.
hauteur (int): Height of the game area.
taille_bloc (int): Size of a grid block.
memoire_max (int): Maximum replay memory size.
"""
graine: int = 42 # Seed for random generation
nb_environnements: int = 50 # Number of parallel envs
largeur: int = 640 # Width of the game area
hauteur: int = 480 # Height of the game area
taille_bloc: int = 20 # Size of a grid block
memoire_max: int = 200000 # Max replay memory size
taille_batch: int = 512 # Main batch size
taille_batch_pqn: int = 512 # PQN specific batch size
memoire_pommes_capacite: int = 20000 # Apple memory capacity
memoire_pommes_seuil: int = 64 # Apple memory threshold
memoire_pommes_echantillons: int = 128 # Apple memory samples
input_size: int = 26 # Model input size
output_size: int = 3 # Model output size
taille_couche_1: int = 256 # First hidden layer size
taille_couche_2: int = 256 # Second hidden layer size
taille_couche_v: int = 128 # Value stream layer size
taille_couche_a: int = 128 # Advantage stream layer size
taux_apprentissage: float = 0.0003 # Learning rate
gamma: float = 0.99 # Discount factor
tau: float = 0.005 # Soft update rate
epsilon_depart: float = 1.0 # Initial exploration rate
epsilon_fin: float = 0.02 # Final exploration rate
epsilon_frames: int = 10000 # Frames to decay epsilon
blend_frames: int = 5000 # Frames for blending
freq_entrainement: int = 8 # Training frequency
n_step: int = 3 # N-step return window
transitions_min_debut: int = 5000 # Min transitions before training
eval_intervalle: int = 5000 # Evaluation interval
nb_episodes_test: int = 100 # Number of test episodes
famine_base: int = 100 # Base starvation limit
famine_par_case: int = 5 # Extra starvation per block
recompense_step: float = -0.001 # Step penalty
recompense_pomme: float = 1.0 # Apple reward
recompense_mort: float = -1.0 # Death penalty
flood_depth_facteur: float = 1 # Flood fill depth factor
flood_depth_max: int = 50 # Flood fill max depth
densite_rayon: int = 5 # Density ray size
scores_historique_maxlen: int = 500 # Max history length for scores
scores_test_maxlen: int = 100 # Max test history length
log_intervalle_sec: float = 1.0 # Log interval in seconds
graph_update_intervalle: int = 100 # Graph update interval
lr_scheduler_epsilon_seuil: float = 0.2 # Epsilon threshold for LR scheduler
lr_scheduler_patience: int = 100 # LR scheduler patience
lr_scheduler_factor: float = 0.5 # LR scheduler factor
lr_min: float = 1e-06 # Minimum learning rate
# ╔══════════════════════════════════════════════════════════╗
# ║ ConfigAffichage ║
# ╠══════════════════════════════════════════════════════════╣
# ║ Handles: ║
# ║ • Display settings and dimensions ║
# ║ • Screenshot capture settings ║
# ╚══════════════════════════════════════════════════════════╝
@dataclass
class ConfigAffichage:
"""
Configuration for the application's UI display parameters.
Attributes:
largeur_fenetre (int): Dashboard total width.
hauteur_fenetre (int): Dashboard total height.
largeur_menu (int): Menu panel width.
hauteur_barre_bas (int): Bottom bar height.
dossier_screenshots (str): Folder for screenshots.
intervalle_screenshot_defaut (int): Default screenshot interval.
"""
largeur_fenetre: int = 1920 # Window width
hauteur_fenetre: int = 1080 # Window height
largeur_menu: int = 250 # Menu width
hauteur_barre_bas: int = 40 # Bottom bar height
dossier_screenshots: str = "screenshots" # Screenshot output folder
intervalle_screenshot_defaut: int = 60 # Screenshot capture interval
# ============================================================
# GLOBAL INSTANCES
# ============================================================
CONFIG = ConfigEntrainement()
CONFIG_UI = ConfigAffichage()