예제 #1
0
def main():
    while True:
        board_size = 19
        try:
            board_size = int(board_size)
        except ValueError:
            print('Invalid Entry')
            continue
        if board_size in range(5, 20):
            break
        else:
            print('Invalid Entry')
    game = goboard.GameState.new_game(board_size)
    bot = bot_1_from_file

    while not game.is_over():
        # print(chr(27) + "[2J")        # We decided not to clear the screen, so we can see the history of the board
        compute_score(game.board)
        print_board(game.board)
        if game.next_player == gotypes.Player.black:
            human_move = input('-- ')
            point = point_from_coords(human_move.strip())
            move = goboard.Move.play(point)
        else:
            move = bot.select_move(game)
        print_move(game.next_player, move)
        game = game.apply_move(move)
예제 #2
0
def main():
    while True:
        board_size = 19
        try:
            board_size = int(board_size)
        except ValueError:
            print('Invalid Entry')
            continue
        if board_size in range(5, 20):
            break
        else:
            print('Invalid Entry')
    game = goboard.GameState.new_game(board_size)
    bots = {
        gotypes.Player.black: bot_1_from_file,
        gotypes.Player.white: bot_2_from_file,
    }
    while not game.is_over():
        time.sleep(0.6)
        # print(chr(27) + "[2J")        # We decided not to clear the screen, so we can see the history of the board
        compute_score(game.board)
        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)
def main():
    while True:
        board_size = input(
            'Enter the dimensions of the square Go board. (Integer between 5 and 19):'
        )
        try:
            board_size = int(board_size)
        except ValueError:
            print('Invalid Entry')
            continue
        if board_size in range(5, 20):
            break
        else:
            print('Invalid Entry')
    game = goboard.GameState.new_game(board_size)
    bots = {
        gotypes.Player.black:
        minimax.alphabeta.AlphaBetaAgent(2, capture_diff),
        gotypes.Player.white:
        minimax.depthprune.DepthPrunedAgent(2, capture_diff),
    }
    while not game.is_over():
        time.sleep(0.3)
        print(chr(27) + "[2J")
        compute_score(game.board)
        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)
예제 #4
0
def main():
    while True:
        board_size = input(
            'Enter the dimensions of the square Go board. (Integer between 5 and 19):'
        )
        try:
            board_size = int(board_size)
        except ValueError:
            print('Invalid Entry')
            continue
        if board_size in range(5, 20):
            break
        else:
            print('Invalid Entry')
    game = goboard.GameState.new_game(board_size)
    bot = agent.RandomBot()

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