Example #1
0
def play_game(generation_name, player_clz, num_previous_states=1):
    game = "breakthrough"

    # ensure we have a network
    man = get_manager()
    generation_descr = templates.default_generation_desc(
        game,
        multiple_policy_heads=True,
        num_previous_states=num_previous_states)

    nn = man.create_new_network(game, "tiny", generation_descr)
    man.save_network(nn, generation_name)
    nn.summary()

    conf = get_default_conf(generation_name,
                            max_dump_depth=2,
                            playouts_per_iteration=42)

    attrutil.pprint(conf)

    gm = GameMaster(lookup.by_name(game))

    gm.add_player(player_clz(conf), "white")
    gm.add_player(get.get_player("random"), "black")

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

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

    gm.finalise_match(last_move)
    return gm
Example #2
0
def play(player_white, player_black, move_time=0.5):
    gm = GameMaster(lookup.by_name(GAME), verbose=True)
    gm.add_player(player_white, "white")
    gm.add_player(player_black, "black")

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

    move = None
    while not gm.finished():

        # print out the board
        pretty_board(BOARD_SIZE, gm.sm)

        move = gm.play_single_move(last_move=move)

    gm.finalise_match(move)