human
I am working on the file "A1/player_notebook.ipynb".
The first task is:
The following are functions that might be useful to you in developing your agent:
game.get_legal_moves(): Returns a list of legal moves for the active player.

game.get_opponent_moves(): Returns a list of legal moves for the inactive player.

game.forecast_move(move): This returns a new board, whose state is the result of making the move specified on the current board.

game.get_state(): This returns a 2D array containing a copy of the explicit state of the board.

game.is_winner(player): Returns whether your player agent has won.

game.is_opponent_winner(player): Returns whether your player's opponent has won.

game.print_board(): Returns a string representation of the game board. This should be useful for debugging.
Can you write Python code for it?
assistant
#Here is the Python code you requested.

class HumanPlayer():
    """Player that chooses a move according to
    user's input."""
    def move(self, game, legal_moves, time_left):
        print('\t'.join(['[%d] %s'%(i,str(move)) for i,move in enumerate(legal_moves)] ))
        
        valid_choice = False
        while not valid_choice:
            try:
                index = int(raw_input('Select move index:'))
                valid_choice = 0 <= index < len(legal_moves)

                if not valid_choice:
                    print('Illegal move! Try again.')
            
            except ValueError:
                print('Invalid index! Try again.')
        return legal_moves[index]