Cleaner random functions used.

This commit is contained in:
SimpleArt
2020-11-20 19:58:25 -05:00
parent 73461f7915
commit 470b33aa31
3 changed files with 9 additions and 9 deletions

View File

@ -72,7 +72,7 @@ class Crossover_Methods:
def single_point(ga, parent_1, parent_2):
"""Cross two parents by swapping genes at one random point."""
swap_index = random.randint(0, len(parent_1)-1)
swap_index = random.randrange(len(parent_1))
return parent_1[:swap_index] + parent_2[swap_index:]