def MaxMin(board, depth): #white turn game.change(board) if depth == 0: return [static(board), board, board] positions = game.generateAdd(board) if not positions: return (static(board), board, board) else: v = [-float('inf'), None, None] for pos in positions: v = max(v, MinMax(pos, depth - 1)[:-1] + [pos], key=lambda x: x[0]) return v
def MidMaxMin(board,depth,a,b):#white turn game.change(board) if depth==0: return [static(board),board,board] flag = checkStep(board) if flag==1 or flag==3: return EndMaxMin(board,depth,a,b) positions = game.generateMove(board) if depth==0 or not positions: return [static(board),board,board] else: v = [-float('inf'),None,None] for pos in positions: v = max(v,MidMinMax(pos,depth-1,a,b)[:-1]+[pos],key = lambda x:x[0]) if(v[0]>=b): return v else: a = max(v[0],a) return v