At least this line
s = [ [0] * 4] * 4
may not do what you think is doing. It does not do the same as
s = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
However, I have not used all the code.
EDIT
OP seems to require more evidence. Here is some output from IDLE showing the difference
>>> s = [ [0] * 4] * 4 >>> s [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] >>> s[0][0] += 1 >>> s [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]] >>> s = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] >>> s [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] >>> s[0][0] += 1 >>> s [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] >>>
The expression s = [ [0] * 4] * 4 creates a list containing another list of zeros, then makes 3 more copies of the link to the list. This is equivalent to v = [0]*4; s=[v,v,v,v] v = [0]*4; s=[v,v,v,v]