File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ def __init__(self, *args):
2121@total_ordering
2222class Action (Enum ):
2323 """Core actions in the Prisoner's Dilemma.
24-
24+
2525 There are only two possible actions, namely Cooperate or Defect,
2626 which are called C and D for convenience.
2727 """
2828
29- C = 1 # Cooperate
30- D = 0 # Defect
29+ C = 0 # Cooperate
30+ D = 1 # Defect
3131
3232 def __lt__ (self , other ):
3333 return self .value < other .value
@@ -36,7 +36,7 @@ def __repr__(self):
3636 return self .name
3737
3838 def __str__ (self ):
39- return repr ( self )
39+ return self . name
4040
4141 def flip (self ):
4242 """Returns the opposite Action."""
@@ -48,7 +48,7 @@ def flip(self):
4848 @classmethod
4949 def from_char (cls , character ):
5050 """Converts a single character into an Action.
51-
51+
5252 Parameters
5353 ----------
5454 character: a string of length one
@@ -91,7 +91,7 @@ def actions_to_str(actions: Iterable[Action]) -> str:
9191
9292 Example: (D, D, C) would be converted to 'DDC'
9393
94- Paramteters
94+ Parameters
9595 -----------
9696 actions: iterable of Action
9797
@@ -100,4 +100,4 @@ def actions_to_str(actions: Iterable[Action]) -> str:
100100 str
101101 A string of 'C's and 'D's.
102102 """
103- return "" .join (map (repr , actions ))
103+ return "" .join (map (str , actions ))
Original file line number Diff line number Diff line change 88
99class TestAction (unittest .TestCase ):
1010 def test_lt (self ):
11- self .assertLess (D , C )
11+ self .assertLess (C , D )
1212
1313 def test_repr (self ):
1414 self .assertEqual (repr (C ), "C" )
You can’t perform that action at this time.
0 commit comments