-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_play_test.py
More file actions
78 lines (75 loc) · 2.99 KB
/
auto_play_test.py
File metadata and controls
78 lines (75 loc) · 2.99 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
"""
This module starts the wizard game GUI as a new window.
last edited: 25.05.2022
author: Sebastian Jost
version 0.2
"""
import time
# import tkinter as tk
# from program_files.wizard_menu_gui import Wizard_Menu_Gui
from program_files.auto_play_games import Wizard_Auto_Play
from program_files.wizard_ais.simple_rule_ai import Simple_Rule_Ai
from program_files.wizard_ais.smart_random_ai import Smart_Random_Ai
from program_files.wizard_ais.uniform_random_ai import Uniform_Random_Ai
from program_files.wizard_ais.genetic_rule_ai import Genetic_Rule_Ai
from program_files.wizard_ais.genetic_nn_ai import Genetic_NN_Ai
def main(n_games=300):
# wizard_gui = Wizard_Menu_Gui()
# tk.mainloop()
auto_play_class = Wizard_Auto_Play(
limit_choices=False,
max_rounds=20,
shuffle_players=True,
ai_player_types=[
# # Uniform random AI
# {"trump_choice_var": Uniform_Random_Ai.name,
# "bids_choice_var": Uniform_Random_Ai.name,
# "get_trick_action": Uniform_Random_Ai.name},
# # Smart random AI
# {"trump_choice_var": Smart_Random_Ai.name,
# "bids_choice_var": Smart_Random_Ai.name,
# "get_trick_action": Smart_Random_Ai.name},
# genetic rule AI 2
{"trump_choice_var": Genetic_Rule_Ai.name,
"bids_choice_var": Genetic_Rule_Ai.name,
"get_trick_action": Genetic_Rule_Ai.name},
# simple rule AI
{"trump_choice_var": Simple_Rule_Ai.name,
"bids_choice_var": Simple_Rule_Ai.name,
"get_trick_action": Simple_Rule_Ai.name},
# genetic rule AI
{"trump_choice_var": Genetic_Rule_Ai.name,
"bids_choice_var": Genetic_Rule_Ai.name,
"get_trick_action": Genetic_Rule_Ai.name},
# # Genetic NN AI
# {"trump_choice_var": Genetic_NN_Ai.name,
# "bids_choice_var": Genetic_NN_Ai.name,
# "get_trick_action": Genetic_NN_Ai.name},
# simple rule AI 2
{"trump_choice_var": Simple_Rule_Ai.name,
"bids_choice_var": Simple_Rule_Ai.name,
"get_trick_action": Simple_Rule_Ai.name},
# # Smart random AI 2
# {"trump_choice_var": Smart_Random_Ai.name,
# "bids_choice_var": Smart_Random_Ai.name,
# "get_trick_action": Smart_Random_Ai.name},
# # Uniform random AI 2
# {"trump_choice_var": Uniform_Random_Ai.name,
# "bids_choice_var": Uniform_Random_Ai.name,
# "get_trick_action": Uniform_Random_Ai.name},
],
n_players=4)
start_time = time.perf_counter()
# stats = auto_play_class.auto_play_single_threaded(
# n_games=n_games, reset_stats=True)
stats = auto_play_class.auto_play_multi_threaded(
n_games=n_games, reset_stats=True)
end_time = time.perf_counter()
# print(f"playing {n_games} games single-threaded took {end_time-start_time} s.")
print(f"playing {n_games} games multi-threaded took {end_time-start_time} s.")
print("average scores:\n", stats[0][-5:-1])
print("win ratios:\n", stats[1][-5:-1])
auto_play_class.plot_results()
if __name__ == "__main__":
# help(plt.legend)
main(n_games=10000)