-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
87 lines (79 loc) · 1.96 KB
/
Copy pathconfig.py
File metadata and controls
87 lines (79 loc) · 1.96 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
"""
Configuration and constants for the Pong AI project.
"""
from pathlib import Path
# Project directories
PROJECT_ROOT = Path(__file__).parent.resolve()
MODELS_DIR = PROJECT_ROOT / "models"
LOGS_DIR = PROJECT_ROOT / "pong_tensorboard"
DEMOS_DIR = PROJECT_ROOT / "demo"
TRAIN_DIR = PROJECT_ROOT / "train"
# Game configuration
GAME_CONFIG = {
'screen_width': 800,
'screen_height': 600,
'paddle_width': 15,
'paddle_height': 100,
'ball_size': 10,
'paddle_speed': 6.0,
'ball_speed': 5.0,
'max_ball_speed': 8.0,
'fps': 60,
}
# RL Training configuration
TRAINING_CONFIG = {
'total_timesteps': 1_000_000,
'num_envs': 4,
'use_multiprocessing': True,
'checkpoint_interval': 50_000,
'learning_rate': 3e-4,
'n_steps': 2048,
'batch_size': 64,
'n_epochs': 10,
'gamma': 0.99,
'gae_lambda': 0.95,
'clip_range': 0.2,
'ent_coef': 0.01,
}
# Model checkpoints available in demo
DEMO_LEVELS = {
'1': {
'path': 'models/rl_model_50000_steps.zip',
'name': 'Novice (50k)',
'description': 'Basic rally pattern learning',
},
'2': {
'path': 'models/rl_model_200000_steps.zip',
'name': 'Intermediate (200k)',
'description': 'Paddle positioning and defense',
},
'3': {
'path': 'models/rl_model_500000_steps.zip',
'name': 'Advanced (500k)',
'description': 'Advanced spike and positioning',
},
'4': {
'path': 'models/rl_model_1000000_steps.zip',
'name': 'Master (1M)',
'description': 'Master-level near-optimal play',
},
}
# API configuration
API_CONFIG = {
'host': '127.0.0.1',
'port': 8000,
'reload': True,
}
# Reward configuration
REWARD_CONFIG = {
'ai_scores': 1.0,
'opponent_scores': -1.0,
'paddle_hit': 0.1,
'step_penalty': -0.001,
}
# Observation normalization
OBSERVATION_CONFIG = {
'ball_velocity_scale': 10.0, # For normalization
'min_value': -1.0,
'max_value': 1.0,
}