Skip to content

Commit aa3837d

Browse files
gaffney2010drvinceknight
authored andcommitted
Fixed Swap Nodes in mutate_rows per issue #41 (#42)
* Fixed Swap Nodes in mutate_rows per issue #41 Swapped based on state, row[0], then sorted. As per our conversation in issue #41 thread. * Updated for fixed swap in mutation
1 parent e798ea2 commit aa3837d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

docs/tutorial/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ We can now evolve our population::
4747
Scoring Generation 2
4848
Generation 2 | Best Score: 2.1 0:C:0_C_0_C:0_D_1_C:1_C_1_D:1_D_1_D
4949
Scoring Generation 3
50-
Generation 3 | Best Score: 2.2 0:C:0_C_0_C:0_D_1_D:1_C_1_D:1_D_1_D
50+
Generation 3 | Best Score: 2.1 0:C:0_C_0_C:0_D_1_C:1_C_1_D:1_D_1_D
5151
Scoring Generation 4
52-
Generation 4 | Best Score: 2.2 0:C:0_C_0_C:0_D_1_D:1_C_1_D:1_D_1_D
52+
Generation 4 | Best Score: 2.1 0:C:0_C_0_C:0_D_1_C:1_C_1_D:1_D_1_D
5353

5454
The :code:`run` command prints out the progress of the algorithm and this is
5555
also written to the output file (we passed :code:`output_filename` as an

src/axelrod_dojo/archetypes/fsm.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ def mutate_rows(rows, mutation_probability):
7474
n1 = randrange(nodes)
7575
n2 = randrange(nodes)
7676
for j, row in enumerate(rows):
77-
if row[1] == n1:
78-
row[1] = n2
79-
elif row[1] == n2:
80-
row[1] = n1
77+
if row[0] == n1:
78+
row[0] = n2
79+
elif row[0] == n2:
80+
row[0] = n1
81+
rows.sort(key=lambda x: (x[0], 0 if x[1]==C else 1))
8182
return rows
8283

8384
def mutate(self):

0 commit comments

Comments
 (0)