-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdebug storage.py
134 lines (122 loc) · 6.31 KB
/
debug storage.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def large_scale_debug(): #massive debug, goes in games.py
average_player = player('{"id" : "average", "name" : "average", "batting_stars" : 2.5, "pitching_stars" : 2.5, "defense_stars" : 2.5, "baserunning_stars" : 2.5}')
max_player = player('{"id" : "max", "name" : "max", "batting_stars" : 5, "pitching_stars" : 5, "defense_stars" : 5, "baserunning_stars" : 5}')
min_player = player('{"id" : "min", "name" : "min", "batting_stars" : 1, "pitching_stars" : 1, "defense_stars" : 1, "baserunning_stars" : 1}')
team_avg = team()
team_avg.add_lineup(average_player)
team_avg.set_pitcher(average_player)
team_avg.finalize()
team_max = team()
team_max.add_lineup(max_player)
team_max.set_pitcher(max_player)
team_max.finalize()
team_min = team()
team_min.add_lineup(min_player)
team_min.set_pitcher(min_player)
team_min.finalize()
average_game = game(team_avg, team_avg)
slugging_game = game(team_max, team_min)
shutout_game = game(team_min, team_max)
hit_count_avg = 0
walk_count_avg = 0
home_run_avg = 0
so_avg = 0
fo_avg = 0
go_avg = 0
for i in range(0,10000):
ab = average_game.at_bat()
if ab["ishit"]:
hit_count_avg += 1
if ab["text"] == appearance_outcomes.homerun:
home_run_avg += 1
elif ab["text"] == appearance_outcomes.walk:
walk_count_avg += 1
elif ab["text"] == appearance_outcomes.strikeoutlooking or ab["text"] == appearance_outcomes.strikeoutswinging:
so_avg += 1
elif ab["text"] == appearance_outcomes.groundout:
go_avg += 1
elif ab["text"] == appearance_outcomes.flyout:
fo_avg += 1
hit_count_slg = 0
walk_count_slg = 0
home_run_slg = 0
fo_slg = 0
go_slg = 0
so_slg = 0
for i in range(0,10000):
ab = slugging_game.at_bat()
if ab["ishit"]:
hit_count_slg += 1
if ab["text"] == appearance_outcomes.homerun:
home_run_slg += 1
elif ab["text"] == appearance_outcomes.walk:
walk_count_slg += 1
elif ab["text"] == appearance_outcomes.strikeoutlooking or ab["text"] == appearance_outcomes.strikeoutswinging:
so_slg += 1
elif ab["text"] == appearance_outcomes.groundout:
go_slg += 1
elif ab["text"] == appearance_outcomes.flyout:
fo_slg += 1
hit_count_sht = 0
walk_count_sht = 0
home_run_sht = 0
go_sht = 0
fo_sht = 0
so_sht = 0
for i in range(0,10000):
ab = shutout_game.at_bat()
if ab["ishit"]:
hit_count_sht += 1
if ab["text"] == appearance_outcomes.homerun:
home_run_sht += 1
elif ab["text"] == appearance_outcomes.walk:
walk_count_sht += 1
elif ab["text"] == appearance_outcomes.strikeoutlooking or ab["text"] == appearance_outcomes.strikeoutswinging:
so_sht += 1
elif ab["text"] == appearance_outcomes.groundout:
go_sht += 1
elif ab["text"] == appearance_outcomes.flyout:
fo_sht += 1
return (hit_count_avg, walk_count_avg, hit_count_slg, walk_count_slg, hit_count_sht, walk_count_sht, home_run_avg, home_run_slg, home_run_sht, so_avg, so_slg, so_sht, go_avg, go_slg, go_sht, fo_avg, fo_slg, fo_sht)
# massive debug function, companion to above. goes in the_prestige
# elif command == "testabs":
# result = games.large_scale_debug()
# await msg.channel.send(f"over 10000 atbats, average player vs average pitcher achieved avg {(result[0]/(10000-result[1]))} and walk rate {result[1]/10000}.")
# await msg.channel.send(f"over 10000 atbats, max player vs min pitcher achieved avg {(result[2]/(10000-result[3]))} and walk rate {result[3]/10000}.")
# await msg.channel.send(f"over 10000 atbats, min player vs max pitcher achieved avg {(result[4]/(10000-result[5]))} and walk rate {result[5]/10000}.")
# await msg.channel.send(f"""there were {result[6]}, {result[7]}, and {result[8]} home runs, respectively.
# there were {result[9]}, {result[10]}, and {result[11]} strikeouts, respectively.
# there were {result[12]}, {result[13]}, and {result[14]} groundouts, respectively.
# there were {result[15]}, {result[16]}, and {result[17]} flyouts, respectively.""")
def debug_game(): #returns a game object ready to run
average_player = player('{"id" : "average", "name" : "AJ", "batting_stars" : 2.5, "pitching_stars" : 2.5, "defense_stars" : 2.5, "baserunning_stars" : 2.5}')
average_player2 = player('{"id" : "average", "name" : "Astrid", "batting_stars" : 2.5, "pitching_stars" : 2.5, "defense_stars" : 2.5, "baserunning_stars" : 2.5}')
average_player3 = player('{"id" : "average", "name" : "xvi", "batting_stars" : 2.5, "pitching_stars" : 2.5, "defense_stars" : 2.5, "baserunning_stars" : 2.5}')
average_player4 = player('{"id" : "average", "name" : "Fox", "batting_stars" : 2.5, "pitching_stars" : 2.5, "defense_stars" : 2.5, "baserunning_stars" : 2.5}')
average_player5 = player('{"id" : "average", "name" : "Pigeon", "batting_stars" : 2.5, "pitching_stars" : 2.5, "defense_stars" : 2.5, "baserunning_stars" : 2.5}')
max_player = player('{"id" : "max", "name" : "max", "batting_stars" : 5, "pitching_stars" : 5, "defense_stars" : 5, "baserunning_stars" : 5}')
min_player = player('{"id" : "min", "name" : "min", "batting_stars" : 1, "pitching_stars" : 1, "defense_stars" : 1, "baserunning_stars" : 1}')
team_avg = team()
team_avg.name = "Arizona Aways"
team_avg.add_lineup(average_player)
team_avg.add_lineup(average_player2)
team_avg.add_lineup(average_player3)
team_avg.add_lineup(average_player4)
team_avg.set_pitcher(average_player5)
team_avg.finalize()
team_avg2 = team()
team_avg2.name = "Houston Homes"
team_avg2.add_lineup(average_player5)
team_avg2.add_lineup(average_player4)
team_avg2.add_lineup(average_player3)
team_avg2.add_lineup(average_player2)
team_avg2.set_pitcher(average_player)
team_avg2.finalize()
team_min = team()
team_min.add_lineup(min_player)
team_min.set_pitcher(min_player)
team_min.finalize()
average_game = game("test", team_avg, team_avg2)
#slugging_game = game(team_max, team_min)
#shutout_game = game(team_min, team_max)
return average_game