Ejemplo n.º 1
0
def do_game(game, gen, players, meta_time, move_time):
    # ensure we have a network

    gm = GameMaster(get_gdl_for_game(game), verbose=False)
    info = lookup.by_name(game)

    for player, role in zip(players, gm.sm.get_roles()):
        gm.add_player(player, role)

    roles = gm.sm.get_roles()
    match_info = create_match_info(meta_time, move_time, len(roles),
                                   game, [p.get_name() for p, r in gm.players], False)

    # save match_info
    update_match_info(game, match_info)

    gm.start(meta_time=meta_time, move_time=move_time)

    the_bs = gm.sm.new_base_state()
    gm.sm.get_current_state(the_bs)
    set_initial_state(match_info, basestate_to_str(info.model, the_bs))

    last_move = None
    while not gm.finished():
        last_move = gm.play_single_move(last_move)

        gm.sm.get_current_state(the_bs)
        add_to_next(match_info, list(last_move), basestate_to_str(info.model, the_bs))

        update_match_info(game, match_info)

    gm.play_to_end(last_move)
    set_goals(match_info, [gm.get_score(r) for _, r in gm.players])

    update_match_info(game, match_info)
Ejemplo n.º 2
0
def test_breakthrough():
    gm = GameMaster(get_gdl_for_game("breakthrough"))

    # add two players
    pymcs = get.get_player("pymcs")
    pymcs.max_run_time = 0.25

    gurgeh = GurgehPlayer("Gurgeh")
    gurgeh.max_tree_search_time = 1
    gurgeh.max_tree_search_time = 1
    gurgeh.thread_workers = 2

    gm.add_player(pymcs, "white")
    gm.add_player(gurgeh, "black")

    gm.start(meta_time=30, move_time=15)
    gm.play_to_end()

    print "white_score", pymcs.name, gm.get_score("white")
    print "black_score", gurgeh.name, gm.get_score("black")