def play_tictactoe_turn(action, state):
    """
    Play a single turn of tictac toe. Returns the next person's turn and the
    new board_state given the input action.

    Input:
         action:
            0-8, an index into the board array

         state:
             board_state:
                (0,1,0,None,None,None,None,None,None),
             a tuple of the board's state

             turn:
                True/False,
             the player's whose turn it is

    Output:
         a new state:
            (True, (0,1,0,None,None,None,None,None,1))
    """

    turn, board_state = state

    board = list(board_state)
    board[action] = int(turn)
    new_turn = not turn
    new_board_state = tuple(board)

    new_state = (new_turn, new_board_state)

    return new_state