Skip to content

Commit fd80dfe

Browse files
committed
Converting docstrings C and D to 'C' and 'D'
Also including an example with m=3 and n=2.
1 parent 2a430e7 commit fd80dfe

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

axelrod/strategies/lookerup.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,53 @@ class LookerUp(Player):
1818
- my last action was a C the opponents
1919
- last action was a D
2020
then the corresponding key would be
21-
(C, C, D)
21+
('C', 'C', 'D')
2222
and the value would contain the action to play on this turn.
2323
2424
Some well-known strategies can be expressed as special cases; for example
2525
Cooperator is given by the dict:
2626
{('', '', '') : C}
2727
where m and n are both zero. Tit-For-Tat is given by:
28+
2829
{
29-
('', C, D) : D,
30-
('', D, D) : D,
31-
('', C, C) : C,
32-
('', D, C) : C,
30+
('', 'C', 'D') : D,
31+
('', 'D', 'D') : D,
32+
('', 'C', 'C') : C,
33+
('', 'D', 'C') : C,
3334
}
35+
3436
where m=1 and n=0.
3537
3638
Lookup tables where the action depends on the opponent's first actions (as
3739
opposed to most recent actions) will have a non-empty first string in the
3840
tuple. For example, this fragment of a dict:
41+
3942
{
4043
...
41-
(C, C, C) : C.
42-
(D, C, C) : D,
44+
('C', 'C', 'C') : C.
45+
('D', 'C', 'C') : D,
4346
...
4447
}
48+
4549
states that if self and opponent both cooperated on the previous turn, we
4650
should cooperate this turn unless the opponent started by defecting, in
4751
which case we should defect.
52+
53+
To denote lookup tables where the action depends on sequences of actions
54+
(so m or n are greater than 1), simply concatenate the strings together.
55+
Below is an incomplete example where m=3 and n=2.
56+
57+
{
58+
...
59+
('CC', 'CDD', 'CCC') : C.
60+
('CD', 'CCD', 'CCC') : D,
61+
...
62+
}
4863
"""
4964

5065
name = 'LookerUp'
5166
classifier = {
52-
'memory_depth': float('inf'),
67+
'memory_depth': float('inf'),
5368
'stochastic': False,
5469
'inspects_source': False,
5570
'manipulates_source': False,
@@ -63,11 +78,11 @@ def __init__(self, lookup_table=None):
6378
Player.__init__(self)
6479

6580
if not lookup_table:
66-
lookup_table = {
67-
('', C, D) : D,
68-
('', D, D) : D,
69-
('', C, C) : C,
70-
('', D, C) : C,
81+
lookup_table = {
82+
('', 'C', 'D') : D,
83+
('', 'D', 'D') : D,
84+
('', 'C', 'C') : C,
85+
('', 'D', 'C') : C,
7186
}
7287

7388
self.lookup_table = lookup_table

0 commit comments

Comments
 (0)