Apr-19-2021, 09:40 AM
- The code run but trying to do these output but did not return me the follow why??
first Enter the number of leaf nodes:
Enter node value:
Enter Depth value:
Enter node value:
The Optimal value:
The codes are follow
maximum, minimum = int(input("Enter the value of alpha is -infinity")),int(input("Enter the value of beta is +infinity")) maximum,minimum = 1000,-1000 def fun_AlphaBeta(depth,node,max_users,value,alpha,beta): if depth ==3: return value[node] if max_users: best = minimum for i in range(0,2): value = fun_Alphabeta(depth+1,node*2+i,False,value,alpha,beta) best = max(best,value) alpha = max(alpha,best) if beta <= alpha: break return best else: best = maximum for i in range(0,2): value = fun_AlphaBeta(depth+1,node*2+i,True,value,alpha,beta) best = min(best,value) beta = min(beta,best) if beta <= alpha: break return best src = [] x = int(input("Enter total number of leaf nodes:")) for i in range(x): y = int(input("Enter node value:")) src.append(y) depth = int(input("Enter Depth value")) node = int(input("Enter node value:")) print("the Optimla value is:",fun_AlphaBeta(depth,node,True,scr,minimum,maximium))