-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
78 lines (63 loc) · 2.84 KB
/
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
71
72
73
74
75
76
77
78
import configparser
import os
import numpy as np
import torch as th
from torch import sigmoid
from minecraft_pb2 import *
class MCSettings:
def __init__(self,
filename: str):
config = configparser.ConfigParser()
config.read(filename)
self.start_coordinates = [
config['START POSITION'].getint('x'),
config['START POSITION'].getint('y'),
config['START POSITION'].getint('z')
]
self.artifact_dimensions = [
config['ARTIFACT'].getint('width'),
config['ARTIFACT'].getint('height'),
config['ARTIFACT'].getint('depth')
]
self.artifact_spacing = config['ARTIFACT'].getint('spacing')
self.evaluable_artifacts = config['ARTIFACT'].getint('evaluable_artifacts')
self.min_block_type_std = config['ARTIFACT'].getfloat('min_block_type_std')
self.min_block_rot_std = config['ARTIFACT'].getfloat('min_block_rot_std')
self.min_air_fraction = config['ARTIFACT'].getfloat('min_air_fraction')
self.min_solid_fraction = config['ARTIFACT'].getfloat('min_solid_fraction')
self.admissible_rotations = config['ADMISSIBILES'].get('rotations').replace(' ', '').upper().split(',')
self.admissible_blocks = config['ADMISSIBILES'].get('blocks').replace(' ', '').upper().split(',')
self.buffer_capacity = config['ESTIMATOR'].getint('buffer_capacity')
self.batch_size = config['ESTIMATOR'].getint('batch_size')
self.conv_channels = config['ESTIMATOR'].getint('conv_channels')
self.train_epochs = config['ESTIMATOR'].getint('train_epochs')
self.train_interval = config['ESTIMATOR'].getint('train_interval')
self.test_threshold = config['ESTIMATOR'].getfloat('test_threshold')
self.nets_folder = os.path.join(os.path.dirname(__file__), config['ESTIMATOR'].get('nets_folder'))
os.makedirs(self.nets_folder, exist_ok=True)
self.history_folder = os.path.join(os.path.dirname(__file__), config['ESTIMATOR'].get('history_folder'))
os.makedirs(self.history_folder, exist_ok=True)
@property
def x0(self):
return self.start_coordinates[0]
@property
def y0(self):
return self.start_coordinates[1]
@property
def z0(self):
return self.start_coordinates[2]
@property
def artifact_width(self):
return self.artifact_dimensions[0]
@property
def artifact_depth(self):
return self.artifact_dimensions[2]
@property
def artifact_height(self):
return self.artifact_dimensions[1]
def val_to_enum(self,
val: float,
block: bool = True):
l = self.admissible_blocks if block else self.admissible_rotations
e = BlockType if block else Orientation
return e.Value(l[int(np.round(val * (len(l) - 1)))])