Skip to content

Commit 581b753

Browse files
committed
Change the way the game is passed to tourn, res.
No longer setting a tournament/resultset class attribute. Everything is done in init.
1 parent cffa849 commit 581b753

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

axelrod/result_set.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def wrapper(*args):
3333

3434
class ResultSet(object):
3535
"""A class to hold the results of a tournament."""
36-
game = Game()
3736

3837
def __init__(self, players, interactions, progress_bar=True, game=None):
3938
"""
@@ -47,7 +46,9 @@ def __init__(self, players, interactions, progress_bar=True, game=None):
4746
progress_bar : bool
4847
Whether or not to create a progress bar which will be updated
4948
"""
50-
if game is not None:
49+
if game is None:
50+
self.game = Game()
51+
else:
5152
self.game = game
5253
self.players = players
5354
self.nplayers = len(players)

axelrod/tournament.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
class Tournament(object):
19-
game = Game()
2019

2120
def __init__(self, players, match_generator=RoundRobinMatches,
2221
name='axelrod', game=None, turns=200, repetitions=10,
@@ -43,12 +42,14 @@ def __init__(self, players, match_generator=RoundRobinMatches,
4342
with_morality : boolean
4443
Whether morality metrics should be calculated
4544
"""
45+
if game is None:
46+
self.game = Game()
47+
else:
48+
self.game = game
4649
self.name = name
4750
self.turns = turns
4851
self.noise = noise
4952
self.num_interactions = 0
50-
if game is not None:
51-
self.game = game
5253
self.players = players
5354
self.repetitions = repetitions
5455
self.match_generator = match_generator(

0 commit comments

Comments
 (0)