Skip to content

Commit adc7f06

Browse files
committed
Changing behaviour to classifier
1 parent 67d73dd commit adc7f06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+227
-227
lines changed

axelrod/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
from .tournament import *
1111
from .tournament_manager import *
1212
from .strategies import *
13-
from .ecosystem import *
13+
from .ecosystem import *

axelrod/player.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Player(object):
2929
"""
3030

3131
name = "Player"
32-
behaviour = {}
33-
default_behaviour = {
32+
classifier = {}
33+
default_classifier = {
3434
'stochastic': False,
3535
'memory_depth': float('inf'),
3636
'inspects_source': None,
@@ -41,14 +41,14 @@ class Player(object):
4141
def __init__(self):
4242
"""Initiates an empty history and 0 score for a player."""
4343
self.history = []
44-
self.behaviour = copy.copy(self.behaviour)
45-
self.behaviour['stochastic'] = (
44+
self.classifier = copy.copy(self.classifier)
45+
self.classifier['stochastic'] = (
4646
"random" in inspect.getsource(self.__class__))
4747
if self.name == "Player":
48-
self.behaviour['stochastic'] = False
49-
for dimension in self.default_behaviour:
50-
if dimension not in self.behaviour:
51-
self.behaviour[dimension] = self.default_behaviour[dimension]
48+
self.classifier['stochastic'] = False
49+
for dimension in self.default_classifier:
50+
if dimension not in self.classifier:
51+
self.classifier[dimension] = self.default_classifier[dimension]
5252
self.tournament_attributes = {'length': -1, 'game': None}
5353
self.cooperations = 0
5454
self.defections = 0

axelrod/round_robin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def _pair_of_players(self, player1_index, player2_index):
9797
def _stochastic_interaction(self, player1, player2):
9898
return (
9999
self._noise or
100-
player1.behaviour['stochastic'] or
101-
player2.behaviour['stochastic'])
100+
player1.classifier['stochastic'] or
101+
player2.classifier['stochastic'])
102102

103103
def _play_single_interaction(self, player1, player2, classes):
104104
turn = 0
@@ -130,7 +130,7 @@ def _cache_update_required(self, p1, p2):
130130
return (
131131
not self._noise and
132132
self.cache_mutable and
133-
not (p1.behaviour['stochastic'] or p2.behaviour['stochastic']))
133+
not (p1.classifier['stochastic'] or p2.classifier['stochastic']))
134134

135135
def _calculate_cooperation(self, player):
136136
return player.history.count('C')

axelrod/strategies/_strategies.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ def is_cheater(s):
137137
"""
138138
A function to check if a strategy cheats.
139139
"""
140-
behaviour = s.behaviour
141-
return behaviour['inspects_source'] or\
142-
behaviour['manipulates_source'] or\
143-
behaviour['manipulates_state']
140+
classifier = s.classifier
141+
return classifier['inspects_source'] or\
142+
classifier['manipulates_source'] or\
143+
classifier['manipulates_state']
144144

145145
ordinary_strategies = [s for s in strategies if not is_cheater(s)]
146146
cheating_strategies = [s for s in strategies if is_cheater(s)]

axelrod/strategies/alternator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Alternator(Player):
55
"""A player who alternates between cooperating and defecting."""
66

77
name = 'Alternator'
8-
behaviour = {
8+
classifier = {
99
'memory_depth': 1,
1010
'stochastic': False,
1111
'inspects_source': False,

axelrod/strategies/appeaser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
class Appeaser(Player):
55
"""A player who tries to guess what the opponent wants.
66
7-
Switch the behaviour every time the opponent plays 'D'.
7+
Switch the classifier every time the opponent plays 'D'.
88
Start with 'C', switch between 'C' and 'D' when opponent plays 'D'.
99
"""
1010

1111
name = 'Appeaser'
12-
behaviour = {
12+
classifier = {
1313
'memory_depth': float('inf'), # Depends on internal memory.
1414
'stochastic': False,
1515
'inspects_source': False,

axelrod/strategies/averagecopier.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class AverageCopier(Player):
88
"""The player will cooperate with probability p if the opponent's cooperation ratio is p."""
99

1010
name = 'Average Copier'
11-
behaviour = {
11+
classifier = {
1212
'memory_depth': float('inf'), # Long memory
1313
'stochastic': True,
1414
'inspects_source': False,
@@ -32,7 +32,7 @@ class NiceAverageCopier(Player):
3232
"""Same as Average Copier, but always starts by cooperating."""
3333

3434
name = 'Nice Average Copier'
35-
behaviour = {
35+
classifier = {
3636
'memory_depth': float('inf'), # Long memory
3737
'stochastic': True,
3838
'inspects_source': False,

axelrod/strategies/axelrod_tournaments.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Davis(Player):
1616
defecting if at any point the opponent has defected."""
1717

1818
name = 'Davis'
19-
behaviour = {
19+
classifier = {
2020
'memory_depth': float('inf'), # Long memory
2121
'stochastic': False,
2222
'inspects_source': False,
@@ -45,7 +45,7 @@ class Feld(Player):
4545
"""
4646

4747
name = "Feld"
48-
behaviour = {
48+
classifier = {
4949
'memory_depth': 200, # Varies actually, eventually becomes depth 1
5050
'stochastic': False,
5151
'inspects_source': False,
@@ -90,7 +90,7 @@ class Shubik(Player):
9090
"""
9191

9292
name = 'Shubik'
93-
behaviour = {
93+
classifier = {
9494
'memory_depth': float('inf'),
9595
'stochastic': False,
9696
'inspects_source': False,
@@ -147,7 +147,7 @@ class Tullock(Player):
147147
than the opponent has in previous rounds."""
148148

149149
name = "Tullock"
150-
behaviour = {
150+
classifier = {
151151
'memory_depth': 11, # long memory, modified by init
152152
'stochastic': False,
153153
'inspects_source': False,
@@ -181,7 +181,7 @@ class Champion(Player):
181181
"""
182182

183183
name = "Champion"
184-
behaviour = {
184+
classifier = {
185185
'memory_depth': float('inf'),
186186
'stochastic': False,
187187
'inspects_source': False,
@@ -215,7 +215,7 @@ class Eatherley(Player):
215215
"""
216216

217217
name = "Eatherley"
218-
behaviour = {
218+
classifier = {
219219
'memory_depth': float('inf'),
220220
'stochastic': False,
221221
'inspects_source': False,
@@ -248,7 +248,7 @@ class Tester(Player):
248248
"""
249249

250250
name = "Tester"
251-
behaviour = {
251+
classifier = {
252252
'memory_depth': float('inf'),
253253
'stochastic': False,
254254
'inspects_source': False,

axelrod/strategies/backstabber.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BackStabber(Player):
88
"""
99

1010
name = 'BackStabber'
11-
behaviour = {
11+
classifier = {
1212
'memory_depth': float('inf'),
1313
'stochastic': False,
1414
'inspects_source': False,
@@ -35,7 +35,7 @@ class DoubleCrosser(Player):
3535
"""
3636

3737
name = 'DoubleCrosser'
38-
behaviour = {
38+
classifier = {
3939
'memory_depth': float('inf'),
4040
'stochastic': False,
4141
'inspects_source': False,

axelrod/strategies/calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Calculator(Player):
1111
"""
1212

1313
name = "Calculator"
14-
behaviour = {
14+
classifier = {
1515
'memory_depth': float('inf'),
1616
'stochastic': True,
1717
'inspects_source': False,

0 commit comments

Comments
 (0)