示例#1
0
"""
import main
import json
from factory import Factory
# how many times does "balanced" need to come out before we accept it as
# "ballenced"
acceptedMinimum = 30 

currentGameCount = 4 # the amount of games we test
change = 4 # how much to increase currentGameCount next time
leeway = 0.05 # fraction of deviation allowed

args = main.parser.parse_args(['-c', 'conf/rlAnd3Rand.json', '--headless', '-l', '0'])
factory = Factory(args)

playerCount = len(factory.createState().players)

def isBalanced(gameCount):
    #if not gameCount % playerCount == 0:
    #    raise ValueError("game count %i has to be devidable by playercount %i" % (gameCount, playerCount))
    scoreboard = dict((p,0) for p in factory.createState().players)
    avgDistance = 0
    for i in range(0,gameCount):
        scores = main.run(factory)
        #if i % (gameCount/100) == 0:
        #    print(int(i/(gameCount/100)),'%', end=" ")
        for score in scores:
            scoreboard[score[0]] += score[1]/gameCount
            avgDistance += (score[1]/playerCount)/gameCount
    i = 0
    score = len(scoreboard.items()) * [None] 
示例#2
0
import main
import json
from factory import Factory
# how many times does "balanced" need to come out before we accept it as
# "ballenced"
acceptedMinimum = 30

currentGameCount = 280  # the amount of games we test
change = 4  # how much to increase currentGameCount next time
leeway = 0.05  # fraction of deviation allowed

args = main.parser.parse_args(
    ['-c', 'conf/tworand.json', '--headless', '-l', '0'])
factory = Factory(args)

playerCount = len(factory.createState().players)


def isBalanced(gameCount):
    if not gameCount % playerCount == 0:
        raise ValueError(
            "game count %i has to be devidable by playercount %i" %
            (gameCount, playerCount))
    scoreboard = dict((p, 0) for p in factory.createState().players)
    avgDistance = 0
    for _ in range(0, gameCount):
        scores = main.run(factory)
        for score in scores:
            scoreboard[score[0]] += score[1] / gameCount
            avgDistance += (score[1] / playerCount) / gameCount