-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.py
83 lines (60 loc) · 2.32 KB
/
printer.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
from termcolor import cprint
def print_code(game):
print("++++++++++++++++++++++++")
text = "CODE : " + str(game.codemaker.code)
cprint(text, "green", attrs=['bold'])
print_knowledge(game, False)
print("++++++++++++++++++++++++")
def print_game_state(i, move, feedback, game):
print("++++++++++++++++++++++++")
text = "Move : " + str(i) + " : " + str(move)
cprint(text, "green", attrs=['bold'])
text = "Feedback : " + str(feedback)
cprint(text, "green", attrs=['bold'])
print_knowledge(game)
print("++++++++++++++++++++++++")
def print_winner(winner):
print("++++++++++++++++++++++++")
text = "WINNER : " + winner
cprint(text, "green", attrs=['bold'])
print("++++++++++++++++++++++++")
def print_knowledge(game, print_worlds=True):
print()
text = "Total worlds possible after this move : " + \
str(len(game.knowledge_manager.model.worlds))
cprint(text, "yellow", attrs=['bold'])
print()
if print_worlds:
for w in game.knowledge_manager.model.worlds:
print(w.name, w.assignment)
print()
print("Real World : ", game.knowledge_manager.real_world)
print("Number of Relations for Agent 1 : ",
len(game.knowledge_manager.model.relations['1']))
print("Number of Relations for Agent 2 : ",
len(game.knowledge_manager.model.relations['2']))
print()
text = "Code Maker Knowledge : "
cprint(text, "yellow", attrs=['bold'])
print(game.agent_knowledge.agent1)
print()
text = "Code Breaker Knowledge : "
cprint(text, "yellow", attrs=['bold'])
print(game.agent_knowledge.agent2)
print()
text = "Common Knowledge : "
cprint(text, "yellow", attrs=['bold'])
print(game.agent_knowledge.common_knowledge)
print()
def print_simulation_results(strategy_analyser):
print("++++++++++++++++++++++++")
print("Total games run for each strategy : ",
strategy_analyser.number_of_games)
print()
print("Games won by Mathematician Code Breaker : ",
strategy_analyser.mathematician_codebreaker_score)
print("Games won by Logician Code Breaker : ",
strategy_analyser.logician_codebreaker_score)
print("Games won by Random Code Breaker : ",
strategy_analyser.random_codebreaker_score)
print("++++++++++++++++++++++++")