Esempio n. 1
0
def main():
    parser = argparse.ArgumentParser(description="BattlePyAI")
    parser.add_argument("--p1", action="store", default='samples.random_player',
                        help="module name of agent for player 1 (eg, samples.random). See code for passing args.",
                        metavar="<dir.file>")
    parser.add_argument("--p2", action="store", default='samples.rando_shotdrissian',
                        help="module name w agent code for player 1 (eg, samples.random)",
                        metavar="<dir.file>")
    parser.add_argument("--vis", action="store_true", default=False,
                        help="Turn on game visualization(slow)")
    parser.add_argument("--games", type=int, action="store", default=1000,
                        help="Number of games to play.",
                        metavar="N")
    parser.add_argument("--debug", action="store_true", default=False,
                        help="Enable debug behavior.")
    args = parser.parse_args()

    p1module, p1arg = unpackPlayerArg(args.p1)
    p2module, p2arg = unpackPlayerArg(args.p2)

    p1 = loadPlayerModule(p1module)
    p2 = loadPlayerModule(p2module)

    # each player is handed an argstring if one was found on the CLI.
    # Thee class can decide what to do with it.
    series = Series(p1(argstring=p1arg),
                    p2(argstring=p2arg),
                    numberOfGames=args.games,
                    showVisualization=args.vis,
                    debug=args.debug,
                    visualizationInterval=.01)
    series.start()
Esempio n. 2
0
def main():
    demo_roster = [
            "samples.rando_shotdrissian",
            "admiralky.admiral3",
            "admiralcatbotdg.admiralcatbotdg",
            "mmalinowskimm.mmalinowskimm",
            "commandermb.commander_bernum",
            "dinghyds.Dinghy",
            "downinflamesjb.downinflames",
            "oaatss.oaatss",
            "buccaneerpg.buccaneer",
            "nelsonis.nelson",
            ]

    parser = argparse.ArgumentParser(description="BattlePyAI Tournament")
    parser.add_argument('players', metavar='<dir.file>', type=str,
                        nargs="*",
                        help="module name w agent code for player (eg, samples.random)"
                        )
    parser.add_argument("--vis", action="store_true", default=False,
                        help="Turn on game visualization(slow)")
    parser.add_argument("--games", type=int, action="store", default=101,
                        help="Number of games to play.",
                        metavar="N")
    parser.add_argument("--debug", action="store_true", default=False,
                        help="Enable debug behavior.")
    args = parser.parse_args()


    if not args.players:
        agent_modules = demo_roster
    else:
        agent_modules = args.players

    players = []
    for agent_module in agent_modules:
        players.append(loadPlayerModule(agent_module))

    tournament = Tournament(players,
                            numberOfGames=args.games,
                            debug=args.debug,
                            showVisualization=args.vis,
                            )
    tournament.run()