-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_settings.py
70 lines (59 loc) · 1.24 KB
/
game_settings.py
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
# Files
SNAKE_WEIGHTS_FILENAME = './model/model_snake.pth'
FOOD_WEIGHTS_FILENAME = './model/model_food.pth'
SCORE_DATA_FILENAME = './data/latest.csv'
# SPRITES
SNAKE_SPRITE_PATH = './sprites/snake_head.png'
# Screen
SCREEN_W = 330
SCREEN_H = 330
# Game
BLOCK_SIZE = 30
DIRECTIONS_QUANTITY = 4
FRAME_RESTRICTION = 300
# Obstacles
MAPS_FOLDER = './maps/'
OBSTACLES_QUANTITY = 0
IS_ADD_OBSTACLES = False
# Speed
GAME_SPEED = 40
SNAKE_SPEED = 0.000004
FOOD_SPEED_MULTIPLIER = 2
# Train
MAX_MEMORY = 100_000
BATCH_SIZE = 1024
SNAKE_ACTION_LENGTH = 3
DROPOUT_RATE = 0.2
LR = 0.001
WEIGHT_DECAY = 1e-5
SNAKE_GAMMA = 0.9
SNAKE_START_EPSILON = 1
SNAKE_MIN_EPSILON = 0.1
EPSILON_SHIFT = 0
SNAKE_ENERGY = 400
TRAINER_STEPS = 4
# Snake vision
CODE_SNAKE = -1
CODE_UNKNOWN = 0
CODE_OBSTACLES = 1
CODE_FOOD = -2
SNAKE_VISION_RANGE = 3
# Snake layers
SNAKE_INPUT_LAYER_SIZE = 57
SNAKE_HIDDEN_LAYER_SIZE1 = 256
SNAKE_HIDDEN_LAYER_SIZE2 = 256
SNAKE_OUTPUT_LAYER_SIZE = 3
# Snake rewards
REWARD_CRAWLING = -0.002
REWARD_ROTATION = -0.001
REWARD_WIN = 10
REWARD_LOOSE = -4
# Food
FOOD_QUANTITY = 1
FOOD_INPUT_LAYER_SIZE = 14
FOOD_HIDDEN_LAYER_SIZE1 = 128
FOOD_HIDDEN_LAYER_SIZE2 = 128
FOOD_OUTPUT_LAYER_SIZE = 4
# Food rewards
BASE_REWARD = 0.1
REWARD_INCREASE_DISTANCE = 1