'Trying to parallelise minimax for tic tac toe, python

I'm trying to parallelise a pretty simple minimax implementation for tic tac toe in python. It's for a reinforcement learning thing but honestly I'm so stuck with this. I haven't done much with parallel computing besides Golang and Golang definitely makes it pretty simple.

Sorry I just don't even know where to start. I'm asking way too much here, but. I've found things about OpenMP, but that's hard to understand too.

Can anyone point me in some direction?

def compMove(board):
  bestScore = -1000
  bestMove = 0

  for index, x in enumerate(board):
    
    if(x == 0):
      board[index] = 2
      score = minimax(board, 0, False)
      board[index] = 0
      if(score > bestScore):
        bestScore = score
        bestMove = index
  return bestMove

def checkDraw(board):
  for index, x in enumerate(board):
    if(x == 0):
      return False
  return True
  


def checkWhoWon(board, mark):
  if(board[0]==board[1] and board[1]==board[2] and board[2]== mark):
    return True
  elif(board[3]==board[4] and board[4]==board[5] and board[5]== mark):
    return True
  elif(board[6]==board[7] and board[7]==board[8] and board[8]== mark):
    return True
  elif(board[0]==board[3] and board[3]==board[6] and board[6]== mark):
    return True
  elif(board[1]==board[4] and board[4]==board[7] and board[7]== mark):
    return True
  elif(board[2]==board[5] and board[5]==board[8] and board[8]== mark):
    return True
  elif(board[0]==board[4] and board[4]==board[8] and board[8]== mark):
    return True
  elif(board[6]==board[4] and board[4]==board[2] and board[2]== mark):
    return True
  else: return False


def minimax(board, depth, isMaximising):
  if checkWhoWon(board, 2):
    return 100
    
  elif checkWhoWon(board, 1):
    return -100
  elif checkDraw(board):
    return 10000
  if isMaximising:
    bestScore = -1000

    for index, x in enumerate(board):
      if(x == 0):
        board[index] = 2
        score = minimax(board, 0, False)
        board[index] = 0
        if(score > bestScore):
          bestScore = score
    return bestScore
  else:
    bestScore = 1000

    for index, x in enumerate(board):
      if(x == 0):
        board[index] = 1
        score = minimax(board, 0, True)
        board[index] = 0
        if(score < bestScore):
          bestScore = score
    return bestScore
  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source