I’m coding conway’s game of life in python, for fun, and i’m using Tkinters.
The main function, called “evolution”, is supposed to calculate, with a given matrix of 1 or 0 depending of a black or white case, the next matrice depending on conway’s game rules.
The fact is that I’m checking every single neighbors of every case of the matrix to the purpose and change it gradually. However, eventhough i created a copied matrix in order for my changes not to affect the real matrix (because conway’s game show the evolution of every cells at the same time and with my methode, the new matrix would interfer with the old one), both matrix are change whenever i try to construct “Fin”, the final matrix. I do not understand because i was tought that copy() methode would solve this problem
My first idea, as I use Tkinter, was that the fact that i was using global variables could create interference and be the source of the problem, but, even after changes variables, the same problem would appearhere is whats it looks like, please note that it is only a part of my function as i need to manage with borders ect, this part alone demonstrate the problem
Adocks 34 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.