Better UI

This commit is contained in:
2019-03-26 12:24:36 +01:00
parent f4587b307e
commit 14cb50e1d2
4 changed files with 36 additions and 30 deletions
View File
+5 -4
View File
@@ -36,10 +36,11 @@ width = 40
height = 40
def run_battle(ai1, ai2):
games = 50
ai1_victories = 0
ai2_victories = 0
for _ in range(50):
for _ in range(games):
initial_position_one = [random.randint(0, width - 1), random.randint(0, height - 1)]
initial_position_two = [random.randint(0, width - 1), random.randint(0, height - 1)]
@@ -66,7 +67,7 @@ def run_battle(ai1, ai2):
elif game.winner == 2:
ai1_victories += 1
return (ai1_victories, ai2_victories)
return (ai1_victories, ai2_victories, 2 * games - ai1_victories - ai2_victories)
def main():
@@ -79,8 +80,8 @@ def main():
continue
print("Battling {} vs {}".format(ai1.name, ai2.name))
(score1, score2) = run_battle(ai1, ai2)
dictionnary["battles"][ai1.name + "/" + ai2.name] = score1 / (score1 + score2)
(score1, score2, nulls) = run_battle(ai1, ai2)
dictionnary["battles"][ai1.name + "/" + ai2.name] = [score1, score2, nulls]
with open("assets/data.json", "w") as f:
f.write(json.dumps(dictionnary))