-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.py
More file actions
54 lines (46 loc) · 1.22 KB
/
Copy pathconstants.py
File metadata and controls
54 lines (46 loc) · 1.22 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
# Color constants
GREEN = (0, 255, 0)
YELLOW = (255, 255, 0)
BLUE_SKY = (135, 206, 235)
# Game constants
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
BIRD_WIDTH = 30
BIRD_HEIGHT = 30
BIRD_X_POSITION = 100
# Physics constants
GRAVITY = 800
FLAP_STRENGTH = -300
BIRD_INITIAL_Y = SCREEN_HEIGHT // 2
# Pipe constants
PIPE_WIDTH = 60
PIPE_GAP_HEIGHT = 150
PIPE_SPEED = 200
PIPE_SPAWN_DISTANCE = 300
PIPE_MIN_GAP_Y = 100
PIPE_MAX_GAP_Y = SCREEN_HEIGHT - 250
# Neural network constants
NN_INPUT_SIZE = 4 # Vectorized bird states: [y_pos, y_velocity, fitness, alive]
NN_HIDDEN1_SIZE = 8
NN_HIDDEN2_SIZE = 16
NN_OUTPUT_SIZE = 1
NN_ARCHITECTURE = [NN_INPUT_SIZE, NN_HIDDEN1_SIZE, NN_HIDDEN2_SIZE, NN_OUTPUT_SIZE]
# Evolution constants
DEFAULT_POPULATION_SIZE = 2000
ELITE_PERCENTAGE = 0.2 # Top 20% as parents
ELITE_SURVIVORS = 10 # Best performers to keep unchangeable
MUTATION_RATE = 0.1
MUTATION_STRENGTH = 0.1
CROSSOVER_THRESHOLD = 0.5
# Simulation constants
DEFAULT_FPS = 60
DEFAULT_GENERATION_TIME = 30
SURVIVAL_POINTS_PER_SECOND = 100
PIPE_PASS_BONUS = 1000
# Constants to normalize NN inputs
Y_POSITION_NORM = 600.0
VELOCITY_NORM = 400.0
DISTANCE_NORM = 800.0
GAP_RELATIVE_NORM = 300.0
# Visualization constants
GENERATION_DISPLAY_INTERVAL = 5