WMICraft/common/constants.py

97 lines
1.7 KiB
Python
Raw Normal View History

2022-04-11 00:01:57 +02:00
from enum import Enum
import torchvision.transforms as transforms
import torch
2022-04-11 00:01:57 +02:00
2022-03-09 16:59:58 +01:00
GAME_TITLE = 'WMICraft'
WINDOW_HEIGHT = 800
WINDOW_WIDTH = 1360
2022-04-10 20:28:50 +02:00
FPS_COUNT = 60
TURN_INTERVAL = 100
2022-04-10 20:28:50 +02:00
2022-03-09 16:59:58 +01:00
GRID_CELL_PADDING = 5
2022-04-10 20:28:50 +02:00
GRID_CELL_SIZE = 36
2022-03-09 16:59:58 +01:00
ROWS = 19
COLUMNS = 24
2022-04-10 20:28:50 +02:00
2022-03-09 16:59:58 +01:00
BORDER_WIDTH = 10
BORDER_RADIUS = 5
2022-04-10 20:28:50 +02:00
2022-03-21 20:30:02 +01:00
KNIGHTS_SPAWN_WIDTH = 4
KNIGHTS_SPAWN_HEIGHT = 7
LEFT_KNIGHTS_SPAWN_FIRST_ROW = 6
LEFT_KNIGHTS_SPAWN_FIRST_COL = 0
RIGHT_KNIGHTS_SPAWN_FIRST_ROW = 6
RIGHT_KNIGHTS_SPAWN_FIRST_COL = 20
2022-03-24 16:32:14 +01:00
CASTLE_SPAWN_WIDTH = 6
CASTLE_SPAWN_HEIGHT = 5
CASTLE_SPAWN_FIRST_ROW = 7
CASTLE_SPAWN_FIRST_COL = 9
2022-04-10 20:28:50 +02:00
NBR_OF_WATER = 16
NBR_OF_TREES = 20
NBR_OF_MONSTERS = 2
2022-04-13 18:35:02 +02:00
NBR_OF_SANDS = 35
2022-04-10 20:28:50 +02:00
2022-03-09 16:59:58 +01:00
TILES = [
'grass1.png',
'grass2.png',
'grass3.png',
2022-04-10 20:28:50 +02:00
'grass4.png',
2022-03-09 16:59:58 +01:00
'sand.png',
'water.png',
'grass_with_tree.jpg',
2022-03-11 19:42:17 +01:00
]
2022-04-11 17:51:46 +02:00
2022-04-11 00:01:57 +02:00
class Direction(Enum):
UP = 0
RIGHT = 1
DOWN = 2
LEFT = 3
2022-04-11 12:00:15 +02:00
def right(self):
2022-04-11 00:01:57 +02:00
v = (self.value + 1) % 4
return Direction(v)
2022-04-11 12:00:15 +02:00
def left(self):
2022-04-11 00:01:57 +02:00
v = (self.value - 1) % 4
return Direction(v)
ACTION = {
"rotate_left": -1,
"rotate_right": 1,
"go": 0,
}
LEFT = 'LEFT'
RIGHT = 'RIGHT'
UP = 'UP'
DOWN = 'DOWN'
2022-04-28 14:13:59 +02:00
# HEALTH_BAR
2022-04-11 17:51:46 +02:00
BAR_ANIMATION_SPEED = 1
2022-04-28 14:13:59 +02:00
BAR_WIDTH_MULTIPLIER = 0.9 # (0;1>
BAR_HEIGHT_MULTIPLIER = 0.1
2022-05-18 10:29:05 +02:00
#NEURAL_NETWORK
2022-05-27 01:38:20 +02:00
LEARNING_RATE = 0.000630957344480193
2022-05-25 19:47:08 +02:00
BATCH_SIZE = 64
2022-05-27 01:38:20 +02:00
NUM_EPOCHS = 9
2022-05-25 19:47:08 +02:00
DEVICE = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
print("Using ", DEVICE)
CLASSES = ['grass', 'sand', 'tree', 'water']
2022-05-25 19:47:08 +02:00
SETUP_PHOTOS = transforms.Compose([
transforms.ToTensor(),
2022-05-26 13:19:17 +02:00
transforms.Resize((36, 36)),
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
])
2022-05-25 19:47:08 +02:00
ID_TO_CLASS = {i: j for i, j in enumerate(CLASSES)}
CLASS_TO_ID = {value: key for key, value in ID_TO_CLASS.items()}