Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01b8ac0

Browse files
ch17,18 improve mutate_move/mudar_mover
1 parent 62a8f45 commit 01b8ac0

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

‎ch17/regexTests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ def mutate_move(genes):
169169
toMove = genes[start:stop]
170170
genes[start:stop] = []
171171
index = random.choice(range(len(genes)))
172+
if index == start:
173+
index += 1
172174
genes[index:index] = toMove
173175
return True
174176

‎ch18/ticTacToeTests.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def mudar_mover(genes):
170170
aMover = genes[principio:fin]
171171
genes[principio:fin] = []
172172
índice = random.choice(range(len(genes)))
173+
if índice == principio:
174+
índice += 1
173175
genes[índice:índice] = aMover
174176
return True
175177

‎es/ch18/ticTacToe.py

Lines changed: 1 addition & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /