improve random_attack

master
Pavel 3 years ago
parent 902b4d11ba
commit 681b67b25d
  1. 18
      python/tipc19py.py

@ -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())

Loading…
Cancel
Save