vendredi 5 novembre 2021

Why my if statement at line 14 and 77 dosen't work? [closed]

class IA(object):

def __init__(self, choice):
    self.choice = choice

def __str__ (self):

    template = '{0.choice}'
    return template.format(self)

def IAs(choice):


    if choice == 1 :
        bool = IA.Tricheur()

        return bool






def Tricheur():
    bool = False


    return bool



def Enfant():
    bool = True
    return bool

def Coequipier(boolean):

    if boolean == True :
        confiance = confiance + 2

    elif boolean ==  False :

        confiance = confiance - (-5)

    if confiance < 0 :

        bool = False
        return bool

    elif confiance >= 0 :

        bool = True
        return bool

def copieur(bool):

    if bool == True :
        booléun = True
    elif bool == False :
        booléun = False

def game(turn,choice1,choice2) :
    count1= 0
    count2= 0
    tour = turn

    while tour != 0 :
        IA1 = IA.IAs(choice1)
        IA2 = IA.IAs(choice2)
        print(tour)
        print(IA1)
        print(IA2)


        if IA1 == False and IA2 == False :
            count1= count1 + 0
            count2 = count2 + 0
            turn = turn - 1

        elif IA1 == False and IA2 == True :

            count1= count1 + 3
            count2 = count2 - 1
            turn = turn - 1

        elif IA1 == True and IA2 == False :

            count1= count1 - 1
            count2 = count2 + 3
            turn = turn - 1

        elif IA1 == True and IA2 == True :

            count1= count1 + 1
            count2 = count2 + 1
            turn = turn - 1

        elif IA1 == None and IA2 == None :
            turn = 0

    return print(f"score 1 : {count1} | score 2 : {count2}")



def main():
    print("""
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     Jeux de la confiance
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        """)

    print("""
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            règles
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        """)

    print("""
        1 - Choisissez qu'elle IA vous voulez faire jouer

        2 - Si les 2 IA mette une pièce chacun gagne 1 points

        3 - Si une IA met une piece et l'autre non, L'IA qui a mis une pièce perd 1 
        point et l'autre gagne 3 points

        4 - si les deux IA ne mette pas de pièce alors aucun ne gagne de point

        5 - vous choisissez le nombre de tour que on fait jouer les IA

        """)





















if __name__ == "__main__":
    main()

print("Choisissez le nombre de tour")
tour=int(input())
print("Choisissez une des IA")
choix1=int(input())
IA1= IA(choix1)
print("Choisissez une autre IA")
choix2=int(input())
IA2= IA(choix2)

game(tour,IA1,IA2)

My if statement when i did the function IAs didn't go in same for the while with the function game

when I enter 1 in the variable choice for the function IAs, the function launch but doesn't go in the if statement. I don't know why. I respect all the indent (I think) Please help me (sorry for my english)

Aucun commentaire:

Enregistrer un commentaire