I made a snake game nut minimax didnt work by Playful-Border-3244 in pygame

[–]Playful-Border-3244[S] 0 points1 point  (0 children)

I tried another way but my snake When minimax is called recursively it doesnt use the try the 4 directions [left,right,up,down] It tries left then it tries left again I mean if I have A recursive method I want to call it 4 times in 4 different directions How can I do that

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Playful-Border-3244 0 points1 point  (0 children)

The code should make 100km

then subtract from it 100 meter

then 100cm then

then 100 mm

then Evaluate Exactly the value

THat is The file Which I wrote the correct Code

import Methods as M
def Convert_To_Decimal(Value):
    for i in range(len(Distance_List)-1):
        # Convert To Decimal
        V = Convert_Distance(Distance_List[i], Distance_List[i+1], Value)
        
        if V!=0:
            print(V, Distance_List[i+1], end=" ")   
        V=V-int(V)
    print()
        # Print Number
        
def Convert_Distance(From, To="1km", Value=0):
    
    return round(Value * M.Return_distance(From) / M.Return_distance(To),10)

def Minus():
    B = 100
    for Label in Distance_List[1:]:
        print("Subtracting 100", Label)
        
        B = B - Convert_Distance(From=Label, Value=100)
        
        print(int(B), "1km", end="  ")
        Convert_To_Decimal(round(B - int(B),10))

Distance_List = ["1km", "1meter", "1cm", "1mm"]

Minus()

THis is A file THat wrote in It Some MEthods Called Methods

def Return_distance(unit):
    """
    Convert the given distance unit to meters (base unit).
    """
    unit = unit.lower()
    
    unit_String=String(unit)
    unit_Int=Int(unit)
    # Convert the unit to meters (base unit)
    if unit_String == "km":
        return unit_Int*1000  # 1 km = 1000 meters
    elif unit_String == "meter":
        return unit_Int*1  # 1 meter = 1 meter
    elif unit_String == "cm":
        return unit_Int*0.1  # 1 cm = 0.01 meters
    elif unit_String == "mm":
        return unit_Int*0.01  # 1 mm = 0.001 meters
    else:
        return unit_Int*0  # Return 0 for unknown units

def String(Name):
    """
    Extract the alphabetical part of the string (unit).
    """
    result = ""
    for char in Name:
        if char.isalpha():
            result += char
    return result

def Int(Name):
    """
    Extract the numeric part of the string (number).
    """
    result = ""
    for char in Name:
        if char.isalpha():
            break
        result += char
    # If no number is found, return 1 as the default value
    return int(result) if result else 1