Пример #1
0
def main(sequences, playerNameArg, numItersArg, sizeArg, debugArg, depthArg,
         probCutoffArg, trainArg, loadArg, saveArg):
    """Primary test harness."""

    startTime = time.time()

    for i, sequence in enumerate(sequences):
        # setup parameters for sequence
        params = generateSequenceParams(sequence, [
            ('playerName', playerNameArg),
            ('numIters', numItersArg),
            ('size', sizeArg),
            ('debug', debugArg),
            ('depth', depthArg),
            ('probCutoff', probCutoffArg),
            ('train', trainArg),
            ('load', loadArg),
            ('save', saveArg),
        ])
        print "Running sequence %d: %s\n" % (i + 1, sequence)
        print "Full parameters: %s\n" % params

        Model.Model.SIZE = params['size']

        if params['playerName'] == PLAYER_NAMES[0]:
            # run the interactive player
            p = Player.InteractivePlayer(debug=params['debug'])
            p.run(numIters=params['numIters'])
        elif params['playerName'] == PLAYER_NAMES[1]:
            # run the baseline greedy player
            p = Player.BaselineGreedyPlayer(debug=params['debug'])
            p.run(numIters=params['numIters'],
                  printStats=True,
                  printAtCheckpoints=True)
        elif params['playerName'] == PLAYER_NAMES[2]:
            # run the baseline corner player
            p = Player.BaselineCornerPlayer(debug=params['debug'])
            p.run(numIters=params['numIters'],
                  printStats=True,
                  printAtCheckpoints=True)
        elif params['playerName'] == PLAYER_NAMES[3]:
            # run the baseline random player
            p = Player.BaselineRandomPlayer(debug=params['debug'])
            p.run(numIters=params['numIters'],
                  printStats=True,
                  printAtCheckpoints=True)
        elif params['playerName'] == PLAYER_NAMES[4]:
            # run the expectimax player
            p = ExpectiMaxPlayer.ExpectiMaxPlayer(
                debug=params['debug'],
                depth=params['depth'],
                probCutoff=params['probCutoff'])
            p.run(numIters=params['numIters'],
                  printStats=True,
                  printAtCheckpoints=True)
        elif params['playerName'] == PLAYER_NAMES[5]:
            # run the RL player
            p = QLPlayer.RLPlayer(debug=params['debug'],
                                  train=params['train'],
                                  load=params['load'],
                                  save=params['save'])
            p.run(numIters=params['numIters'],
                  printStats=True,
                  printAtCheckpoints=True)

        runTime = time.time() - startTime
        print "\nTotal runtime after %d sequence(s): %.3f seconds" % (i + 1,
                                                                      runTime)

        if i != len(sequences) - 1:
            print "\n\n"
Пример #2
0
 def setUp(self):
     self.p = Player.BaselineCornerPlayer()