input: Write a function that creates a Tic-Tac-Toe reinforcement learning environment in Python. The function should define a class named TicTacToeEnv with methods for initializing the environment, resetting the game, performing a step with an action, and checking for a winner. The function should also include a demonstration of playing a game using the environment.
  
  assert TicTacToeEnv().check_winner() == None
  assert TicTacToeEnv().reset() == [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
  assert TicTacToeEnv().step(0) == (['X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], 0, False, None)
  assert TicTacToeEnv().step(1) == (['X', 'O', ' ', ' ', ' ', ' ', ' ', ' ', ' '], 0, False, None)
output: class TicTacToeEnv:
      def __init__(self):
          self.board = [' '] * 9
          self.current_player = 'X'
  
      def reset(self):
          self.board = [' '] * 9
          self.current_player = 'X'
          return self.board
  
      def step(self, action):
          if self.board[action] != ' ':
              return self.board, -1, True, None
          self.board[action] = self.current_player
          winner = self.check_winner()
          done = winner is not None or ' ' not in self.board
          reward = 1 if winner == self.current_player else 0
          self.current_player = 'O' if self.current_player == 'X' else 'X'
          return self.board, reward, done, winner
  
      def check_winner(self):
          lines = [
              [0, 1, 2], [3, 4, 5], [6, 7, 8],  # rows
              [0, 3, 6], [1, 4, 7], [2, 5, 8],  # columns
              [0, 4, 8], [2, 4, 6]              # diagonals
          ]
          for line in lines:
              if self.board[line[0]] == self.board[line[1]] == self.board[line[2]] != ' ':
                  return self.board[line[0]]
          return None