So basically I have a main 2d array called grid filled with cell objects and I create a clone of this array called gridN for later use but when I set all of gridN's density to 0 the main grid's density is set to 0 aswell. This can be seen because the print on the last couple of lines returns 0.
class cell:
x = 0
y = 0
den = 0
velX = 0
velY = 0
width = 10
height = 10
grid = []
for i in range(width):
grid.append([])
for j in range(height):
grid[i].append(cell())
grid[i][j].x = i
grid[i][j].y = j
def diffuse(k,grid):
gridN = list(grid)
for i in range(width):
gridN.append([])
for j in range(height):
gridN[i].append(cell())
gridN[i][j].den = 0
print(gridN[0][0].den)
grid[0][0].den = 100
diffuse(0.5,grid)
I tried adding some things to stop both arrays from accessing the same memory like:
list()
[:]
.copy()