-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecological.py
57 lines (49 loc) · 1.69 KB
/
ecological.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
# Copyright Florentin Schleuß 2020-2022. Licensed under
# the EUPL-1.2 or later
import axelrod as axl
from tools import plot_eco, run_tournament
import io
from datetime import datetime
def pretty_print(no, tournament):
# Pretty print
pretty = "Playing Tournament No. " + str(no) + "\n"
pretty += "Players: "
pretty += str(tournament.players) + "\n\n"
pretty += "Player Data:\n"
for player in (tournament.summarise()):
pretty += str(player) + "\n"
pretty += "\n\n"
with io.open("classical_results.txt", "a") as file:
file.write(pretty)
"""
Reset output file
"""
with io.open("classical_results.txt", "w") as file:
file.write(datetime.now().strftime("%d/%m/%Y %H:%M:%S") + "\n\n")
"""
Tournament One
"""
players = [axl.Cooperator(), axl.Defector(), \
axl.Grudger(), axl.CyclerCCD(), \
axl.TitForTat()]
tournament = run_tournament(players)
pretty_print(1, tournament)
plot_eco(results=tournament, reproduce=20, title="Tournament One", logscale=False)
"""
Tournament Two
"""
players = [axl.Cooperator(), axl.Defector(), \
axl.Grudger(), axl.CyclerCCD(), \
axl.TitForTat(), axl.GoByMajority()]
tournament = run_tournament(players)
pretty_print(2, tournament)
plot_eco(results=tournament, reproduce=20, title="Tournament Two", logscale=False)
#players = [axl.Calculator(), axl.Prober(), \
# axl.Punisher(), axl.Defector(), \
# axl.TitForTat(), axl.GoByMajority(), \
# axl.OriginalGradual(), axl.Random()]
# plot_eco(run_tournament(players))
players = [axl.Cooperator(), axl.Defector(), axl.CyclerCCD()]
tournament = run_tournament(players)
pretty_print(3, tournament)
plot_eco(results=tournament, reproduce=20, title="Tournament Three", logscale=False)