forked from SirDeMox/Macke_Trudeln
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_session.py
101 lines (87 loc) · 2.93 KB
/
run_session.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from play_game import PlayGame
import pandas as pd
from play_game import PlayGame
class RunSession():
def __init__(self,
method="earlystop",
threshold=300,
special=[],):
"""
This class runs games until it reaches 5k total_score
and returns a summary of all games played
:param method: either "earlystop" or "nrolls"
:param threshold: a integer which goes with the method
:param special: a list containing special options as strings
"""
self.method = method
self.threshold = threshold
self.final_score = 0
self.macke_counter = 0
self.game_counter = 0
self.current_game = None
self.missed_points = 0
self.threshold_curved = None
self.special = special
self.curve = {0: 0,
1: 250,
2: 500,
3: 750,
4: 1000,
5: 1250,
6: 1500,
7: 1750,
8: 2000,
9: 2250,
10: 2500,
11: 2750,
12: 3000,
13: 3250,
14: 3500,
15: 3750,
16: 4000,
17: 4250,
18: 4500,
19: 4750,
20: 5000,}
def curve_state_interpreter(self):
# calc diff curve versus total
# if diff > X:
# raise/lower threshold
# if diff < Y:
# raise/lower threshold
if self.curve_state == "behind":
self.threshold_curved = 500
if self.curve_state == "ahead":
self.threshold_curved = 250
def play_until_5k(self):
"""
this method runs PlayGame and scores the games until it reached 5k points.
it runs a game, scores the points in final_score and ++ the game_counter counter
if the game ended in a Macke, it will ++ the macke_counter
:return: None
"""
while self.final_score < 5000:
#todo curve interpreter here!?
#self.curve_state_interpreter()
#replace threshold below
self.current_game = PlayGame(
method=self.method,
threshold=self.threshold,
special=self.special,
)
self.current_game.run()
self.final_score += self.current_game.total_score
self.game_counter += 1
if self.current_game.stopping_reason == "Macke":
self.macke_counter += 1
self.missed_points += self.current_game.score_before_end
def create_output_dict(self):
return {
"method": self.method,
"threshold": self.threshold,
"special": self.special,
"final_score": self.final_score,
"games_n": self.game_counter,
"macke_counter": self.macke_counter,
"missed_points": self.missed_points,
}