Deterministic run

This commit is contained in:
Thomas Forgione 2019-03-27 14:40:18 +01:00
parent fcc78a3f9f
commit b3f3417335
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
4 changed files with 56 additions and 17 deletions

2
pytron

@ -1 +1 @@
Subproject commit 5d1c96407b665e138784431cf0046537065bfaee
Subproject commit b2504f49f9e30e3ffa07ec3ab11d6b465829b593

View File

@ -1,8 +0,0 @@
from tron.player import Player, Direction
class Ai(Player):
def __init__(self):
super(Ai, self).__init__()
def action(self, map, id):
return Direction.LEFT

53
pytron_run/positions.py Normal file
View File

@ -0,0 +1,53 @@
def positions():
return [
[(4, 4), (5, 5)],
[(0, 0), (0, 9)],
[(0, 4), (0, 5)],
[(1, 2), (1, 7)],
[(7, 2), (2, 7)],
[(3, 2), (6, 7)],
[(9, 4), (0, 5)],
[(9, 0), (4, 9)],
[(7, 3), (0, 6)],
[(6, 7), (4, 8)],
[(8, 6), (9, 2)],
[(4, 3), (3, 1)],
[(1, 9), (0, 9)],
[(2, 9), (0, 9)],
[(9, 9), (3, 9)],
[(4, 2), (3, 2)],
[(3, 7), (7, 4)],
[(6, 6), (1, 4)],
[(4, 3), (0, 1)],
[(7, 3), (3, 8)],
[(3, 5), (5, 2)],
[(4, 2), (8, 5)],
[(2, 6), (3, 8)],
[(4, 0), (4, 9)],
[(9, 9), (2, 0)],
[(5, 1), (8, 1)],
[(5, 2), (2, 2)],
[(0, 7), (0, 8)],
[(6, 9), (9, 6)],
[(2, 9), (9, 4)],
[(0, 9), (4, 1)],
[(3, 5), (2, 7)],
[(6, 2), (7, 4)],
[(8, 7), (2, 3)],
[(9, 2), (1, 6)],
[(9, 4), (1, 1)],
[(2, 5), (3, 8)],
[(3, 1), (6, 8)],
[(7, 0), (1, 9)],
[(6, 3), (1, 6)],
[(4, 1), (5, 5)],
[(5, 9), (0, 6)],
[(9, 8), (0, 5)],
[(9, 1), (8, 0)],
[(7, 0), (1, 9)],
[(2, 1), (2, 5)],
[(7, 2), (4, 5)],
[(9, 2), (5, 6)],
[(8, 0), (0, 6)],
[(3, 1), (3, 9)],
]

View File

@ -2,8 +2,6 @@
import sys
import json
import random
random.seed()
sys.path.append('../pytron')
from tron.map import Map
@ -12,6 +10,7 @@ from tron.player import Direction, ConstantPlayer
from importlib import import_module
import positions
import ai_manager
# Find all the AIs
@ -40,12 +39,7 @@ def run_battle(ai1, ai2):
ai1_victories = 0
ai2_victories = 0
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)]
while initial_position_one[0] == initial_position_two[0] and initial_position_one[1] == initial_position_two[1]:
initial_position_two = [random.randint(0, width - 1), random.randint(0, height - 1)]
for (initial_position_one, initial_position_two) in positions.positions():
game = Game(width, height, [
PositionPlayer(1, ai1.builder(), initial_position_one),
PositionPlayer(2, ai2.builder(), initial_position_two),