Home Why it does not save the nodes of the tree (Python)
Reply: 0

Why it does not save the nodes of the tree (Python)

mattia stroppolatini
1#
mattia stroppolatini Published in 2017-12-06 03:15:53Z

i made this code that should create a tree for a tris game for every possible outcome of the game from a starting 3x3 list. when doing gen_tree it creates the said three but whe i use the function scorri it shows that only the first nodotris object actually saved his leafs, in fact when scorri searches for child nodes in lista_figli it gets blank lists

def gen_tree(griglia):
nodo=NodoTris(griglia)
nodo.nome=griglia
tip=nodo.tipo()
vuoti=vuoto(griglia)
if tip=='?':
    x=0
    y=0
    while x<3:
        y=0
        while y<3:
            if nodo.nome[x][y]=='':
                nodof=NodoTris(nodo.nome)
                nodof.nome=copy.deepcopy(nodo.nome)
                if vuoti%2==0:
                    nodof.nome[x][y]='x'
                else:
                    nodof.nome[x][y]='o'    
                nodo.lista_figli.append(nodof)
            y+=1
        x+=1


for n in nodo.lista_figli:
    gen_tree(n.nome)

scorri(nodo)   
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.335675 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO