fixed shallow copy problem

This commit is contained in:
Stephen McQuay 2012-10-25 22:14:49 -07:00
parent 360668c4d3
commit 8505476cbb

View File

@ -1,5 +1,5 @@
import copy import copy
import random from random import randint
class CS235Maze(object): class CS235Maze(object):
@ -20,10 +20,11 @@ class CS235Maze(object):
def make_maze(size=8): def make_maze(size=8):
r = [[[0] * size] * size] * size r = []
for i in xrange(size): for i in xrange(size):
r.append([])
for j in xrange(size): for j in xrange(size):
r[i][j] = [random.randint(0, 1) for i in xrange(size)] r[i].append([randint(0, 1) for k in xrange(size)])
r[0][0][0] = 1 r[0][0][0] = 1
r[7][7][7] = 1 r[7][7][7] = 1
return CS235Maze(r, size) return CS235Maze(r, size)