Skip to content

Commit

Permalink
Correct all the wrong usages.
Browse files Browse the repository at this point in the history
  • Loading branch information
skytreader committed Mar 11, 2017
1 parent b903431 commit d0ac694
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ai/ga/mastermind_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ def mutate(self, variation):
f_count = sum([1 for d in variation_decision if not d])

guess_correct = self.__pick_distinct_subset(variation, t_count)
print("guess correct %s" % guess_correct)
guess_misplaced = self.__pick_distinct_subset(variation, f_count, autoexclude=guess_correct)
print("guess misplaced %s" % guess_misplaced)

for item in guess_correct:
assert item not in guess_misplaced

untouchables = set()
untouchables.union(guess_correct)
untouchables.union(guess_misplaced)
untouchables = guess_correct.union(guess_misplaced)
varindices = set(range(len(variation)))
replaceables = varindices - untouchables

for misplaced in guess_misplaced:
swap_index = self.__pick_distinct_subset(variation, 1, guess_correct).pop()
varclone[misplaced], varclone[swap_index] = varclone[swap_index], varclone[misplaced]

if swap_index in replaceables:
replaceables.remove(swap_index)
replaceables.add(misplaced)

for replace in replaceables:
varclone[replace] = random.choice(self.mastermind.charset)

Expand Down

0 comments on commit d0ac694

Please sign in to comment.