Пример #1
0
def main():
    board_size = 6
    game = connect5_board.GameState.new_game(board_size)
    bots = {
        types.Player.black:
        AZAgent(board_size, torch.load(sys.argv[1]), rounds_per_move=400),
        types.Player.white:
        AZAgent(board_size, torch.load(sys.argv[2]), rounds_per_move=400),
    }

    while not game.is_over():
        time.sleep(0.3)

        print(chr(27) + "[2J")
        print_board(game.board)
        bot_move = bots[game.next_player].select_move(game)
        print_move(game.next_player, bot_move)
        game = game.apply_move(bot_move)

    print(chr(27) + "[2J")
    print_board(game.board)

    if game.winner is "Draw":
        print("Draw!")
    else:
        print("Winner is %s!" % game.winner)
Пример #2
0
def main():
    game = connect5_board.GameState.new_game(BOARD_SIZE)
    bot = mcts.MCTSAgent(100, temperature=1.25)

    while not game.is_over():
        print_board(game.board)
        if game.next_player == types.Player.black:
            human_move = input('-- ')
            point = point_from_coords(human_move.strip())
            move = connect5_board.Move.play(point)
        else:
            move = bot.select_move(game)
        print_move(game.next_player, move)
        game = game.apply_move(move)
def main():
    game = connect5_board.GameState.new_game(BOARD_SIZE)
    # 사용하고 싶은 bot을 넣어주세요.
    bot = AZAgent(BOARD_SIZE, torch.load(sys.argv[1]), rounds_per_move=400)

    # bot의 name을 정합니다. 다른 팀과 중복되면 안됩니다.
    name = 'c301-bot'

    # 서버와의 통신에 사용되는 Connect5Connecter 클래스 객체를 만듭니다.
    # connecter 관련 부분은 수정하지 말아주세요. 서버랑 통신할 때 문제가 생깁니다.
    connecter = Connect5Connecter(HOST, name)

    # 서버에서 자기 차례에 state를 가져옵니다.
    state = connecter.get_state()
    # 서버에서 정해준 bot의 color로 is_my_turn을 결정합니다.
    if state['color'] == 'black':
        print("I'm black.")
        is_my_turn = True
    elif state['color'] == 'white':
        print("I'm white.")
        is_my_turn = False
    else:
        print('invalid color')

    while not game.is_over():
        # 서버에서 자기 차례에 state를 가져옵니다.
        state = connecter.get_state()
        # bot의 차례라면 send_action으로 서버에 bot의 action을 전송합니다.
        # 아니면 서버에서 oppnent의 action을 가져와 game에 적용합니다.
        if is_my_turn:
            move = bot.select_move(game)
            game = game.apply_move(move)
            connecter.send_action(move.point.col, move.point.row)
        else:
            move = connect5_board.Move.play(
                types.Point(row=int(state['opponent_action']['y']),
                            col=int(state['opponent_action']['x'])))
            game = game.apply_move(move)
        print_board(game.board)
        # is_my_turn을 뒤집습니다.
        is_my_turn = not is_my_turn

    # 누가 이겼는지 서버에 알려줍니다.
    connecter.notice_winner(game.winner)
Пример #4
0
def main():
    board_size = 8
    game = connect5_board.GameState.new_game(board_size)
    bot = C302Bot(1000, 1.01, presuggestion, 3, 0.4, 5)

    while not game.is_over():
        print_board(game.board)
        if game.next_player == types.Player.black:
            human_move = input('-- ')
            point = point_from_coords(human_move.strip())
            move = connect5_board.Move.play(point)
        else:
            move = bot.select_move(game)
        print_move(game.next_player, move)
        game = game.apply_move(move)

    print_board(game.board)

    if game.winner is "Draw":
        print("Draw!")
    else:
        print("Winner is %s!" % game.winner)
Пример #5
0
def main():
    board_size = 9
    game = connect5_board.GameState.new_game(board_size)
    bot = agent.RandomBot()

    while not game.is_over():
        print(chr(27) + "[2J")
        print_board(game.board)
        if game.next_player == types.Player.black:
            human_move = input('-- ')
            point = point_from_coords(human_move.strip())
            move = connect5_board.Move.play(point)
        else:
            move = bot.select_move(game)
        print_move(game.next_player, move)
        game = game.apply_move(move)

    print(chr(27) + "[2J")
    print_board(game.board)

    if game.winner is "Draw":
        print("Draw!")
    else:
        print("Winner is %s!" % game.winner)
Пример #6
0
def main():
    board_size = 8
    game = connect5_board.GameState.new_game(board_size)
    bots = {
        types.Player.black: agent.C402bot.CBot(800, 1.4),
        types.Player.white: agent.C402bot.CBot(800, 1.4),
    }

    while not game.is_over():
        time.sleep(0.3)

        print(chr(27) + "[2J")
        print_board(game.board)
        bot_move = bots[game.next_player].select_move(game)
        print_move(game.next_player, bot_move)
        game = game.apply_move(bot_move)

    print(chr(27) + "[2J")
    print_board(game.board)

    if game.winner is "Draw":
        print("Draw!")
    else:
        print("Winner is %s!" % game.winner)
Пример #7
0
def main():
    board_size = 6
    game = connect5_board.GameState.new_game(board_size)
    bot = AZAgent(board_size, torch.load(sys.argv[1]), rounds_per_move=400)

    while not game.is_over():
        print(chr(27) + "[2J")
        print_board(game.board)
        if game.next_player == types.Player.black:
            human_move = input('-- ')
            point = point_from_coords(human_move.strip())
            move = connect5_board.Move.play(point)
        else:
            move = bot.select_move(game)
        print_move(game.next_player, move)
        game = game.apply_move(move)

    print(chr(27) + "[2J")
    print_board(game.board)

    if game.winner is "Draw":
        print("Draw!")
    else:
        print("Winner is %s!" % game.winner)