input: Write a function to develop an AI-based Tic-Tac-Toe game using Python. The function should include the following components: a function to print the game board, a function to check if a player has won, a function to decide the computer's move, and the main game loop. The game should alternate between the human player (using the 'X' marker) and the computer (using the 'O' marker). If the board is full and no one has won, the game should end in a draw. The function should not take any input but should initiate the game when called.
  
  def playGame(): 
      board = ['-' for x in range(10)] 
      won = False
      turn = -1
      while not won: 
          if turn == -1: 
              # human turn   
              humanSpot = int(input("Enter your spot: "))
              if board[humanSpot] == '-': 
                  board[humanSpot] = 'X' 
              else: 
                  print("The spot is already filled!") 
                  continue
              turn *= -1
         
          if checkWin(board,'X'): 
              drawBoard(board) 
              print("You won!") 
              won = True
              break
            
          if turn == 1: 
              # computer turn  
              computerSpot = getComputerSpot(board,'O') 
              if computerSpot == None: 
                  drawBoard(board) 
                  print("The game is drawn!")
                  break
              else: 
                  board[computerSpot] = 'O' 
              turn *= -1
                
          drawBoard(board)
  
  # Define the function to print the game board
  def drawBoard(board):
      print("---------------") 
      print(" "+board[1]+" | "+board[2]+" | "+board[3]+" ") 
      print("___|___|___") 
      print(" "+board[4]+" | "+board[5]+" | "+board[6]+" ") 
      print("___|___|___") 
      print(" "+board[7]+" | "+board[8]+" | "+board[9]+" ") 
      print("   |   |   ")
  
  # Define the function to check if a player has won
  def checkWin(board, player): 
      return ( 
          (board[1] == board[2] == board[3] == player) or
          (board[5] == board[4] == board[6] == player) or 
          (board[7] == board[8] == board[9] == player) or 
          (board[1] == board[5] == board[9] == player) or 
          (board[3] == board[5] == board[7] == player) or 
          (board[1] == board[4] == board[7] == player) or 
          (board[2] == board[5] == board[8] == player) or 
          (board[3] == board[6] == board[9] == player))
  
  # Define the function for the computer's move
  def getComputerSpot(board,player): 
      openSpots = [] 
      indices = [i for i, spot in enumerate(board) if spot == '-'] 
      
      for i in indices: 
          board[i] = player  
            
          if checkWin(board, player):  
              board[i] = '-'  
              return i  
          board[i] = '-'  
            
      for i in indices: 
          openSpots.append(i) 
      if len(openSpots): 
          return random.choice(openSpots) 
      else: 
          return None
  
  assert playGame()
output: 
  def playGame(): 
      board = ['-' for x in range(10)] 
      won = False
      turn = -1
      while not won: 
          if turn == -1: 
              # human turn   
              humanSpot = int(input("Enter your spot: "))
              if board[humanSpot] == '-': 
                  board[humanSpot] = 'X' 
              else: 
                  print("The spot is already filled!") 
                  continue
              turn *= -1
         
          if checkWin(board,'X'): 
              drawBoard(board) 
              print("You won!") 
              won = True
              break
            
          if turn == 1: 
              # computer turn  
              computerSpot = getComputerSpot(board,'O') 
              if computerSpot == None: 
                  drawBoard(board) 
                  print("The game is drawn!")
                  break
              else: 
                  board[computerSpot] = 'O' 
              turn *= -1
                
          drawBoard(board)
  
  def drawBoard(board):
      print("---------------") 
      print(" "+board[1]+" | "+board[2]+" | "+board[3]+" ") 
      print("___|___|___") 
      print(" "+board[4]+" | "+board[5]+" | "+board[6]+" ") 
      print("___|___|___") 
      print(" "+board[7]+" | "+board[8]+" | "+board[9]+" ") 
      print("   |   |   ")
  
  def checkWin(board, player): 
      return ( 
          (board[1] == board[2] == board[3] == player) or
          (board[5] == board[4] == board[6] == player) or 
          (board[7] == board[8] == board[9] == player) or 
          (board[1] == board[5] == board[9] == player) or 
          (board[3] == board[5] == board[7] == player) or 
          (board[1] == board[4] == board[7] == player) or 
          (board[2] == board[5] == board[8] == player) or 
          (board[3] == board[6] == board[9] == player))
  
  def getComputerSpot(board,player): 
      openSpots = [] 
      indices = [i for i, spot in enumerate(board) if spot == '-'] 
      
      for i in indices: 
          board[i] = player  
            
          if checkWin(board, player):  
              board[i] = '-'  
              return i  
          board[i] = '-'  
            
      for i in indices: 
          openSpots.append(i) 
      if len(openSpots): 
          return random.choice(openSpots) 
      else: 
          return None
  