Skip to content

Commit

Permalink
Grid shouldn't be randomizing things, GOL should.
Browse files Browse the repository at this point in the history
  • Loading branch information
mythmon committed Mar 20, 2011
1 parent d23ca38 commit 7db3e9c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions grid.py
Expand Up @@ -73,10 +73,6 @@ def __init__(self, screen, w=25, h=25):
# Make a grid of zeros.
self.w, self.h = w, h
self.grid = [[0] * self.h for _ in range(self.w)]
for _ in range(int(self.w * self.h * 0.5)):
x = int(random()*self.w)
y = int(random()*self.h)
self.grid[x][y] = 1

self.colors = [(1,1,1), (0,0,0)]

Expand Down Expand Up @@ -111,12 +107,10 @@ class GOL(Grid):

def __init__(self, screen, w, h):
super(GOL, self).__init__(screen, w, h)
for x in range(w):
self.grid[x][0] = 0
self.grid[x][h-1] = 0
for y in range(h):
self.grid[0][y] = 0
self.grid[w-1][y] = 0
for _ in range(int(self.w * self.h * 0.5)):
x = int(random()*(self.w-2))+1
y = int(random()*(self.h-2))+1
self.grid[x][y] = 1

def tick(self):
grid_copy = [row[:] for row in self.grid]
Expand Down

0 comments on commit 7db3e9c

Please sign in to comment.