Morpion Python

Fermé
Noven - 30 déc. 2021 à 19:45
yg_be Messages postés 23329 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 17 novembre 2024 - 30 déc. 2021 à 20:16
Bonjour, pour un travail de première spécialité NSI, je dois realiser un morpion avec Python, j'ai reussi à faire un programme pour jouer en 1vs1 et contre un ordi qui joue au hasard et la j'essayais de faire un programme pour faire jouer l'ordi intelligemment mais c'est un désastre.. J'ai ici plusieurs tentatives on va dire mais je sais plus quoi faire..

def ordid():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
       
    
        if t[0]==t[1]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
            
        elif t[2]==t[1]!=" ":
             a=1
             if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[2]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[3]==t[4]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
            
        elif t[4]==t[5]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[3]==t[5]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[6]==t[7]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[7]==t[8]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[6]==t[8]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[3]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[3]==t[6]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[6]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[1]==t[4]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[4]==t[7]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[1]==t[7]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[2]==t[5]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
        elif t[8]==t[5]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
        elif t[2]==t[8]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
            
        elif t[0]==t[4]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[8]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[4]==t[8]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[2]==t[4]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[4]==t[6]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
        elif t[2]==t[6]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif a==10:
            a=random.randint(1,10)
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )

def ordi():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
        while a==10:
    
            if t[0]==t[1]!=" ":
                a=3
                
            
            if t[2]==t[1]!=" ":
                a=1
                
        
            if t[0]==t[2]!=" ":
                a=2
                
        
            if t[3]==t[4]!=" ":
                a=6
                
            
            if t[4]==t[5]!=" ":
                a=4
                return
        
            if t[3]==t[5]!=" ":
                a=5
                return
        
            if t[6]==t[7]!=" ":
                a=9
        
            if t[7]==t[8]!=" ":
                a=7
                return
        
            if t[6]==t[8]!=" ":
                a=8
                return
        
            if t[0]==t[3]!=" ":
                a=7
                return
        
            if t[3]==t[6]!=" ":
                a=1
                return
        
            if t[0]==t[6]!=" ":
                a=4
                return
        
            if t[1]==t[4]!=" ":
                a=8
                return
            
            if t[4]==t[7]!=" ":
                a=2
                return
        
            if t[1]==t[7]!=" ":
                a=5
                return
        
            if t[2]==t[5]!=" ":
                a=9
                return
    
            if t[8]==t[5]!=" ":
                a=3
                return
    
            if t[2]==t[8]!=" ":
                a=6
                return
            
            if t[0]==t[4]!=" ":
                a=9
                return
        
            if t[0]==t[8]!=" ":
                a=5
                return
        
            if t[4]==t[8]!=" ":
                a=1
                return
        
            if t[2]==t[4]!=" ":
                a=7
                return
        
            if t[4]==t[6]!=" ":
                a=3
                return
    
            if t[2]==t[6]!=" ":
                a=5
                return
        
            if a==10:
                a=random.randint(1,10)
                return
            
        if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        else:
            a=random.randint(1,10)
            
        if test_case_occupe(a) == True:
            
                
            t[a-1]=str("O")
            test=True
            t2[a-1]=1
            
        print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )



def ordiO():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
       
    
        if t[0]==t[1]!=" ":
            a=3
            
        elif t[2]==t[1]!=" ":
             a=1
        
        elif t[0]==t[2]!=" ":
            a=2
        
        elif t[3]==t[4]!=" ":
            a=6
            
        elif t[4]==t[5]!=" ":
            a=4
        
        elif t[3]==t[5]!=" ":
            a=5
        
        elif t[6]==t[7]!=" ":
            a=9
        
        elif t[7]==t[8]!=" ":
            a=7
        
        elif t[6]==t[8]!=" ":
            a=8
        
        elif t[0]==t[3]!=" ":
            a=7
        
        elif t[3]==t[6]!=" ":
            a=1
        
        elif t[0]==t[6]!=" ":
            a=4
        
        elif t[1]==t[4]!=" ":
            a=8
        
        elif t[4]==t[7]!=" ":
            a=2
        
        elif t[1]==t[7]!=" ":
            a=5
        
        elif t[2]==t[5]!=" ":
            a=9    
    
        elif t[8]==t[5]!=" ":
            a=3
    
        elif t[2]==t[8]!=" ":
            a=6
            
        elif t[0]==t[4]!=" ":
            a=9
        
        elif t[0]==t[8]!=" ":
            a=5
        
        elif t[4]==t[8]!=" ":
            a=1
        
        elif t[2]==t[4]!=" ":
            a=7
        
        elif t[4]==t[6]!=" ":
            a=3
    
        elif t[2]==t[6]!=" ":
            a=5
        
        else:
            a=random.randint(1,10)
        if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        else:
            a=random.randint(1,10)
            
        if test_case_occupe(a) == True:
            
                
            t[a-1]=str("O")
            test=True
            t2[a-1]=1
            
        print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )


def ordip():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
       
    
        if t[0]==t[1]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
            
        elif t[2]==t[1]!=" ":
             a=1
             if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[2]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[3]==t[4]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
            
        elif t[4]==t[5]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[3]==t[5]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[6]==t[7]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[7]==t[8]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[6]==t[8]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[3]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[3]==t[6]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[6]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[1]==t[4]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[4]==t[7]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[1]==t[7]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[2]==t[5]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
    
        elif t[8]==t[5]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
    
        elif t[2]==t[8]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
            
        elif t[0]==t[4]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[8]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[4]==t[8]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[2]==t[4]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[4]==t[6]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
    
        elif t[2]==t[6]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif a==10:
            a=random.randint(1,10)
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
       
            
        print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )




2 réponses

mon code en entier :
t=[" "," "," "," "," "," "," "," "," "]
t2=[0,0,0,0,0,0,0,0,0]
#print(" ", t[0], " | " , t[1]," | ",t[2]," \n ---------------- \n " , t[3]," | " , t[4]," | ", t[5]," \n ---------------- \n ", t[6] ," | ",t[7]," | ",t[8],"  " )
print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
#print(" ", "1", " | " , "2"," | ","3"," \n ---------------- \n " , "4"," | " , "5"," | ", "6"," \n ---------------- \n ", "7" ," | ","8"," | ","9","  " )



def test_case_occupe(case):
    case=case-1
    if t2[case]==0:
        return True
    else:
        return False

def j1():
    winX()
    test=False
    
    while test==False:
        
        a=input("tu veux jouer en quelle case ? (1 à 9)")
        a=int(a)
        
        if a>9 :
            print("choisis une case entre 1 et 9 s'il te plait !")
            return j1()
            
        if a<1:
            print("choisis une case entre 1 et 9 s'il te plait !")
            return j1()
            
        
        if test_case_occupe(a) == True:
            
            t[a-1]=str("X")
            test=True
            t2[a-1]=1
            
        elif test_case_occupe(a) == False :
            print("Cette case est déjà occupée")
        
    print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )       


def j2():
    winO()
    test=False
    
    while test==False:
        
        a=input("tu veux jouer en quelle case ? (1 à 9)")
        a=int(a)
        
        
        
        if a>9 :
            print("choisis une case entre 1 et 9 s'il te plait !")
            return j2()
            
        if a<1:
            print("choisis une case entre 1 et 9 s'il te plait !")
            return j2()
        
        if test_case_occupe(a) == True:
            
            t[a-1]=str("O")
            test=True
            t2[a-1]=1
            
        elif test_case_occupe(a) == False :
            print("Cette case est déjà occupée")
        
    print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
    
    
def vs():
    
    while winO()==False and winX()==False and nul()==False:
        j1()
        if winO()==False and winX()==False and nul()==False:
            j2()
            
    if winO()==True:
        print("partie terminée, O a gagné")
        return
    if winX()==True:
        print("partie terminée, X a gagné")
        return
    if nul()==True:
        print("Partie nulle")
        
    
    
def winX():
      
    if t[0]==t[1]==t[2]=="X" or t[0]==t[3]==t[6]=="X" or t[0]==t[4]==t[8]=="X" or t[3]==t[4]==t[5]=="X" or t[6]==t[7]==t[8]=="X" or t[1]==t[4]==t[7]=="X" or t[2]==t[5]==t[8]=="X" or t[2]==t[4]==t[6]=="X":
        return True
    
    else :
        return False
    
    
def winO():
    
    if t[0]==t[1]==t[2]=="O" or t[0]==t[3]==t[6]=="O" or t[0]==t[4]==t[8]=="O" or t[3]==t[4]==t[5]=="O" or t[6]==t[7]==t[8]=="O" or t[1]==t[4]==t[7]=="O" or t[2]==t[5]==t[8]=="O" or t[2]==t[4]==t[6]=="O":
        return True
    
    else :
        return False
    
    
def nul():
    
    if t[0] != " " and t[1] != " " and t[2] != " " and t[3] != " " and t[4] != " " and t[5] != " " and t[6] != " " and t[7] != " " and t[8] != " ":
        return True
    
    else:
        return False
    
import random

def ponyo():
    #aussi bête que Ponyo <3
    winO()
    test=False
    
    while test==False:
        
        a=random.randint(1,10)
        
        if test_case_occupe(a) == True:
            
            t[a-1]=str("O")
            test=True
            t2[a-1]=1
        
        
    print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
def vsponyo():
    while winO()==False and winX()==False and nul()==False:
        j1()
        if winO()==False and winX()==False and nul()==False:
            ponyo()
            
    if winO()==True:
        print("partie terminée, O a gagné")
        return
    if winX()==True:
        print("partie terminée, X a gagné")
        return
    if nul()==True:
        print("Partie nulle")


def test():
    a=10
    a=int(a)
    
    if t[0]==t[1]!=" ":
        a=3
     
    elif t[2]==t[1]!=" ":
         a=1
        
    elif t[0]==t[2]!=" ":
        a=2
        
    elif t[3]==t[4]!=" ":
        a=6
        
    elif t[4]==t[5]!=" ":
        a=4
        
    elif t[3]==t[5]!=" ":
        a=5
        
    elif t[6]==t[7]!=" ":
        a=9
        
    elif t[7]==t[8]!=" ":
        a=7
        
    elif t[6]==t[8]!=" ":
        a=8
        
    elif t[0]==t[3]!=" ":
        a=7
        
    elif t[3]==t[6]!=" ":
        a=1
        
    elif t[0]==t[6]!=" ":
        a=4
        
    elif t[1]==t[4]!=" ":
        a=8
        
    elif t[4]==t[7]!=" ":
        a=2
        
    elif t[1]==t[7]!=" ":
        a=5
        
    elif t[2]==t[5]!=" ":
        a=9    
    
    elif t[8]==t[5]!=" ":
        a=3
    
    elif t[2]==t[8]!=" ":
        a=6
            
    elif t[0]==t[4]!=" ":
        a=9
        
    elif t[0]==t[8]!=" ":
        a=5
        
    elif t[4]==t[8]!=" ":
        a=1
        
    elif t[2]==t[4]!=" ":
        a=7
        
    elif t[4]==t[6]!=" ":
        a=3
    
    elif t[2]==t[6]!=" ":
        a=5
        
    elif a==10:
        a=random.randint(1,10)

def ordi():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
        while a==10:
    
            if t[0]==t[1]!=" ":
                a=3
                
            
            if t[2]==t[1]!=" ":
                a=1
                
        
            if t[0]==t[2]!=" ":
                a=2
                
        
            if t[3]==t[4]!=" ":
                a=6
                
            
            if t[4]==t[5]!=" ":
                a=4
                return
        
            if t[3]==t[5]!=" ":
                a=5
                return
        
            if t[6]==t[7]!=" ":
                a=9
        
            if t[7]==t[8]!=" ":
                a=7
                return
        
            if t[6]==t[8]!=" ":
                a=8
                return
        
            if t[0]==t[3]!=" ":
                a=7
                return
        
            if t[3]==t[6]!=" ":
                a=1
                return
        
            if t[0]==t[6]!=" ":
                a=4
                return
        
            if t[1]==t[4]!=" ":
                a=8
                return
            
            if t[4]==t[7]!=" ":
                a=2
                return
        
            if t[1]==t[7]!=" ":
                a=5
                return
        
            if t[2]==t[5]!=" ":
                a=9
                return
    
            if t[8]==t[5]!=" ":
                a=3
                return
    
            if t[2]==t[8]!=" ":
                a=6
                return
            
            if t[0]==t[4]!=" ":
                a=9
                return
        
            if t[0]==t[8]!=" ":
                a=5
                return
        
            if t[4]==t[8]!=" ":
                a=1
                return
        
            if t[2]==t[4]!=" ":
                a=7
                return
        
            if t[4]==t[6]!=" ":
                a=3
                return
    
            if t[2]==t[6]!=" ":
                a=5
                return
        
            if a==10:
                a=random.randint(1,10)
                return
            
        if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        else:
            a=random.randint(1,10)
            
        if test_case_occupe(a) == True:
            
                
            t[a-1]=str("O")
            test=True
            t2[a-1]=1
            
        print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )



def ordiO():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
       
    
        if t[0]==t[1]!=" ":
            a=3
            
        elif t[2]==t[1]!=" ":
             a=1
        
        elif t[0]==t[2]!=" ":
            a=2
        
        elif t[3]==t[4]!=" ":
            a=6
            
        elif t[4]==t[5]!=" ":
            a=4
        
        elif t[3]==t[5]!=" ":
            a=5
        
        elif t[6]==t[7]!=" ":
            a=9
        
        elif t[7]==t[8]!=" ":
            a=7
        
        elif t[6]==t[8]!=" ":
            a=8
        
        elif t[0]==t[3]!=" ":
            a=7
        
        elif t[3]==t[6]!=" ":
            a=1
        
        elif t[0]==t[6]!=" ":
            a=4
        
        elif t[1]==t[4]!=" ":
            a=8
        
        elif t[4]==t[7]!=" ":
            a=2
        
        elif t[1]==t[7]!=" ":
            a=5
        
        elif t[2]==t[5]!=" ":
            a=9    
    
        elif t[8]==t[5]!=" ":
            a=3
    
        elif t[2]==t[8]!=" ":
            a=6
            
        elif t[0]==t[4]!=" ":
            a=9
        
        elif t[0]==t[8]!=" ":
            a=5
        
        elif t[4]==t[8]!=" ":
            a=1
        
        elif t[2]==t[4]!=" ":
            a=7
        
        elif t[4]==t[6]!=" ":
            a=3
    
        elif t[2]==t[6]!=" ":
            a=5
        
        else:
            a=random.randint(1,10)
        if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        else:
            a=random.randint(1,10)
            
        if test_case_occupe(a) == True:
            
                
            t[a-1]=str("O")
            test=True
            t2[a-1]=1
            
        print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )


def ordip():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
       
    
        if t[0]==t[1]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
            
        elif t[2]==t[1]!=" ":
             a=1
             if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[2]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[3]==t[4]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
            
        elif t[4]==t[5]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[3]==t[5]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[6]==t[7]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[7]==t[8]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[6]==t[8]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[3]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[3]==t[6]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[6]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[1]==t[4]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[4]==t[7]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[1]==t[7]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[2]==t[5]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
    
        elif t[8]==t[5]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
    
        elif t[2]==t[8]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
            
        elif t[0]==t[4]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[0]==t[8]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[4]==t[8]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[2]==t[4]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif t[4]==t[6]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
    
        elif t[2]==t[6]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
        
        elif a==10:
            a=random.randint(1,10)
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
       
            
        print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )



def ordid():
    test=False
    
    a=10
    a=int(a) 
        
    while test==False:
       
       
    
        if t[0]==t[1]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
            
        elif t[2]==t[1]!=" ":
             a=1
             if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[2]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[3]==t[4]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
            
        elif t[4]==t[5]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[3]==t[5]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[6]==t[7]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[7]==t[8]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[6]==t[8]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[3]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[3]==t[6]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[6]!=" ":
            a=4
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[1]==t[4]!=" ":
            a=8
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[4]==t[7]!=" ":
            a=2
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[1]==t[7]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[2]==t[5]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
        elif t[8]==t[5]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
        elif t[2]==t[8]!=" ":
            a=6
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
            
        elif t[0]==t[4]!=" ":
            a=9
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[0]==t[8]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[4]==t[8]!=" ":
            a=1
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[2]==t[4]!=" ":
            a=7
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif t[4]==t[6]!=" ":
            a=3
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
    
        elif t[2]==t[6]!=" ":
            a=5
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
        
        elif a==10:
            a=random.randint(1,10)
            if test_case_occupe(a) == True:
            
                t[a-1]=str("O")
                test=True
                t2[a-1]=1
                print("\n ",t[0],"|" , t[1],"|",t[2],"             1 | 2 | 3 \n -----------            ----------- \n " , t[3],"|" , t[4],"|", t[5],"             4 | 5 | 6 \n -----------            ----------- \n ", t[6] ,"|",t[7],"|",t[8],"             7 | 8 | 9   \n" )
       
            
        


def vsordi():
    while winO()==False and winX()==False and nul()==False:
        j1()
        if winO()==False and winX()==False and nul()==False:
            ordid()
            
    if winO()==True:
        print("partie terminée, O a gagné")
        return
    if winX()==True:
        print("partie terminée, X a gagné")
        return
    if nul()==True:
        print("Partie nulle")
0
yg_be Messages postés 23329 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 17 novembre 2024 Ambassadeur 1 551
30 déc. 2021 à 20:16
bonjour, "c'est un désastre": as-tu un message d'erreur?
0