|
5 | 5 | import axelrod as axl |
6 | 6 | import matplotlib.pyplot as plt |
7 | 7 |
|
8 | | -first_tournament_participants_ordered_by_reported_rank = [s() for s in axl.axelrod_first_strategies] |
9 | | -number_of_strategies = len(first_tournament_participants_ordered_by_reported_rank) |
| 8 | +first_tournament_participants_ordered_by_reported_rank = [ |
| 9 | + s() for s in axl.axelrod_first_strategies |
| 10 | +] |
| 11 | +number_of_strategies = len( |
| 12 | + first_tournament_participants_ordered_by_reported_rank |
| 13 | +) |
10 | 14 | axl.seed(0) |
11 | 15 | tournament = axl.Tournament( |
12 | | - players=first_tournament_participants_ordered_by_reported_rank, |
13 | | - turns=200, |
14 | | - repetitions=5 |
| 16 | + players=first_tournament_participants_ordered_by_reported_rank, |
| 17 | + turns=200, |
| 18 | + repetitions=5, |
15 | 19 | ) |
16 | 20 | results = tournament.play() |
17 | 21 |
|
18 | 22 | plt.figure(figsize=(15, 6)) |
19 | 23 | plt.plot((0, 15), (0, 15), color="grey", linestyle="--") |
20 | | -for original_rank, strategy in enumerate(first_tournament_participants_ordered_by_reported_rank): |
| 24 | +for original_rank, strategy in enumerate( |
| 25 | + first_tournament_participants_ordered_by_reported_rank |
| 26 | +): |
21 | 27 | rank = results.ranked_names.index(str(strategy)) |
22 | 28 | if rank == original_rank: |
23 | 29 | symbol = "+" |
24 | 30 | plt.plot((rank, rank), (rank, 0), color="grey") |
25 | 31 | else: |
26 | 32 | symbol = "o" |
27 | 33 | plt.scatter([rank], [original_rank], marker=symbol, color="black", s=50) |
28 | | -plt.xticks( |
29 | | - range(number_of_strategies), |
30 | | - results.ranked_names, |
31 | | - rotation=90 |
32 | | -) |
| 34 | +plt.xticks(range(number_of_strategies), results.ranked_names, rotation=90) |
33 | 35 | plt.ylabel("Reported rank") |
34 | | -plt.xlabel("Reproduced rank"); |
| 36 | +plt.xlabel("Reproduced rank") |
35 | 37 | plt.savefig("rank_comparison.svg") |
36 | 38 |
|
37 | 39 | plot = axl.Plot(results) |
|
0 commit comments