-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_test_multiprocess.py
More file actions
82 lines (70 loc) · 3.06 KB
/
make_test_multiprocess.py
File metadata and controls
82 lines (70 loc) · 3.06 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
from modules.TestManager import TestMapManager, TestGamesManager
import time
import logging
'''
D:\PythonProjects\Alpha_gold\.venv\Scripts\python.exe D:\PythonProjects\Alpha_gold\make_test.py
'''
if __name__ == "__main__":
#TODO LOOK AHEAD PARAM
#TODO seed od do
#TOTO by zmenijszyć liczbę stanów do liczenia robimy next wave dla 5 ruchów by
start_time = time.time()
msg="""Rework drzewa z rolloutem dla next wave, nieograniczony rollout jednak ograniczona liczba next waveów. test dla wielu leveli . LH=0 """
game_test = TestGamesManager()
params = {
'msg':msg,
'start_time': start_time,
'save_results': True,
'repeats_iterations': 200,
'mcts_n_simulations': 250,
'mcts_max_new_wave':3,
'mcts_greedy_selection':True,
'mcts_rollout_max_depth': 50,
'display_board': False,
'min_level': 5,
'max_level': 5,
'test_function': 'mcts_play'
}
try:
game_test.make_test(params)
game_test.create_csv_dataframe()
game_test.main_path.joinpath('_SUCCESS').touch()
end_time = time.time()
elapsed_time = end_time - start_time
hours, remainder = divmod(elapsed_time, 3600)
minutes, seconds = divmod(remainder, 60)
formatted_time = "{:02}:{:02}:{:02}".format(int(hours), int(minutes), int(seconds))
logging.info(f"Execution time: {formatted_time}")
except KeyboardInterrupt as keyboard:
end_time = time.time()
elapsed_time = end_time - start_time
hours, remainder = divmod(elapsed_time, 3600)
minutes, seconds = divmod(remainder, 60)
formatted_time = "{:02}:{:02}:{:02}".format(int(hours), int(minutes), int(seconds))
logging.info(f"Execution interrupted after: {formatted_time} seconds")
logging.error('Interapted')
if not game_test.main_path.exists():
game_test.main_path.mkdir(exist_ok=True, parents=True)
failed_file = game_test.main_path.joinpath('FAILED.txt')
with open(failed_file, 'w') as f:
f.write('PARAMS\n')
for key, value in params.items():
f.write(f'{key}: {value}\n')
f.write('\nERROR\n')
f.write('Interapted')
except Exception as err:
end_time = time.time()
elapsed_time = end_time - start_time
hours, remainder = divmod(elapsed_time, 3600)
minutes, seconds = divmod(remainder, 60)
formatted_time = "{:02}:{:02}:{:02}".format(int(hours), int(minutes), int(seconds))
logging.error(f"Execution failed after: {formatted_time} seconds", exc_info=True)
if not game_test.main_path.exists():
game_test.main_path.mkdir(exist_ok=True, parents=True)
failed_file = game_test.main_path.joinpath('FAILED.txt')
with open(failed_file, 'w') as f:
f.write('PARAMS\n')
for key, value in params.items():
f.write(f'{key}: {value}\n')
f.write('\nERROR\n')
f.write(str(err)) # You should write 'err' not 'Exception'