Skip to content

Commit 7ffe121

Browse files
committed
ch17,18 use >= vice == in mutate_move/mudar_mover
- provides more diversity in the results per Greg Eakin see: https://dotnetfiddle.net/ko2TgS
1 parent 9aade01 commit 7ffe121

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

ch17/regexTests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def mutate_move(genes):
169169
toMove = genes[start:stop]
170170
genes[start:stop] = []
171171
index = random.choice(range(len(genes)))
172-
if index == start:
172+
if index >= start:
173173
index += 1
174174
genes[index:index] = toMove
175175
return True

ch18/ticTacToeTests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def mutate_move(genes):
200200
toMove = genes[start:stop]
201201
genes[start:stop] = []
202202
index = random.choice(range(len(genes)))
203-
if index == start:
203+
if index >= start:
204204
index += 1
205205
genes[index:index] = toMove
206206
return True

es/ch17/regex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def mudar_mover(genes):
170170
aMover = genes[principio:fin]
171171
genes[principio:fin] = []
172172
índice = random.choice(range(len(genes)))
173-
if índice == principio:
173+
if índice >= principio:
174174
índice += 1
175175
genes[índice:índice] = aMover
176176
return True

es/ch18/ticTacToe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def mudar_mover(genes):
200200
aMover = genes[principio:fin]
201201
genes[principio:fin] = []
202202
índice = random.choice(range(len(genes)))
203-
if índice == principio:
203+
if índice >= principio:
204204
índice += 1
205205
genes[índice:índice] = aMover
206206
return True

0 commit comments

Comments
 (0)