Python Forum
Run the code for some stuff it does not return me why
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run the code for some stuff it does not return me why
#1

  1. 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))
Reply
#2
The following lines
    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))
Are indented into your function fun_AlphaBeta
Anldra12 likes this post
Reply
#3
(Apr-19-2021, 11:50 AM)Yoriz Wrote: The following lines
    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))
Are indented into your function fun_AlphaBeta
Reply
#4
oh my god yes you right thanks a lot
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to print stuff from while loop Nick1507 4 2,280 Sep-17-2020, 02:26 PM
Last Post: Nick1507
  code doesnt return anything ofrihemo 3 1,987 Jun-30-2020, 05:14 PM
Last Post: ofrihemo
  How Do I Install Stuff for Python? CopBlaster 6 3,132 May-08-2020, 12:27 PM
Last Post: hussainmujtaba
  Learning to have Class and doing stuff with it... bako 2 1,957 Apr-29-2020, 05:07 PM
Last Post: bako
  Automate the boring stuff : the tic tac toe game DJ_Qu 7 6,578 Apr-24-2019, 12:22 PM
Last Post: ichabod801
  python code (embedded in Redshift) to return result of the query Mel 0 2,409 Aug-24-2018, 06:12 PM
Last Post: Mel
  More List Stuff Zman350x 3 3,380 Mar-11-2018, 12:20 AM
Last Post: Zman350x
  Need help importing stuff that python says it cant open Tiaan 2 2,805 Nov-30-2017, 09:54 PM
Last Post: Tiaan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020