Exemplo n.º 1
0
def play_game(board_name, game_time, h_params):
    board = utils.get_board_from_csv(board_name)
    player_1 = sys.modules["players.CompetePlayer"].Player(
        game_time=game_time, penalty_score=300, heuristic_params=ref_params)
    player_2 = sys.modules["players.CompetePlayer"].Player(
        game_time=game_time, penalty_score=300, heuristic_params=h_params)

    game = GameWrapper(
        board[0],
        board[1],
        board[2],
        player_1=player_1,
        player_2=player_2,
        terminal_viz=True,
        print_game_in_terminal=False,
        time_to_make_a_move=game_time,
        game_time=game_time,
        penalty_score=300,
    )
    return game.start_game()
Exemplo n.º 2
0
        print("saar")
        raise Exception(f'Wrong board file type argument, {board_file_type}.')
    if not args.board in os.listdir('boards'):
        raise Exception(f'Board file {args.board} does not exist in "boards" directory.')

    # Players inherit from AbstractPlayer - this allows maximum flexibility and modularity
    player_1_type = 'players.' + args.player1
    player_2_type = 'players.' + args.player2
    game_time = args.game_time
    penalty_score = args.penalty_score
    __import__(player_1_type)
    __import__(player_2_type)
    player_1 = sys.modules[player_1_type].Player(game_time, penalty_score)
    player_2 = sys.modules[player_2_type].Player(game_time, penalty_score)

    board = utils.get_board_from_csv(args.board)

    # print game info to terminal
    print('Starting Game!')
    print(args.player1, 'VS', args.player2)
    print('Board', args.board)
    print('Players have', args.move_time, 'seconds to make a signle move.')
    print('Each player has', game_time, 'seconds to play in a game (global game time, sum of all moves).')

    # create game with the given args
    game = GameWrapper(board[0], board[1], board[2], player_1=player_1, player_2=player_2,
                    terminal_viz=args.terminal_viz, 
                    print_game_in_terminal=not args.dont_print_game,
                    time_to_make_a_move=args.move_time, 
                    game_time=game_time, 
                    penalty_score = args.penalty_score,