improve random_attack

This commit is contained in:
Pavel 2019-11-07 11:07:23 +01:00
parent 902b4d11ba
commit 681b67b25d
1 changed files with 9 additions and 9 deletions

View File

@ -132,22 +132,22 @@ def random_pokemon(code):
def random_attack(code):
score_max = fast_score(code)
for k in range(300):
code_next = code.copy()
i = 10
j = 10
while i == j:
while True:
i = randint(10, 19)
j = randint(10, 19)
if i != j:
break
d = randint(-93, 93)
vi = code_next[i] + d
vj = code_next[j] - d
vi = code[i] + d
vj = code[j] - d
if vi >= 0 and vi <= 93 and vj >= 0 and vj <= 93:
code_next = code.copy()
code_next[i] = vi
code_next[j] = vj
score = fast_score(code_next)
if score_max < score:
score_next = fast_score(code_next)
if score_max < score_next:
code[:] = code_next
score_max = score
score_max = score_next
seed(time())