Commits

Owen Nelson committed cc2ba18

dropping the gui portion of the repo (now a in a different package)

Comments (0)

Files changed (3)

     _state = None
     _iter = None
 
+    def new_state(self, size):
+        return np.random.randint(2, size=size)
+
     def __init__(self, size=None, state=None):
         if state is None:
             if size is None:
-                size = (20, 20)
-            state = np.random.randint(2, size=size)
-
+                size = (50, 50)
+            state = self.new_state(size)
         self.load_state(state)
 
     def load_state(self, state):
     def __iter__(self):
         while 1:
             yield tick(self._state)
-            # yield self._state
 
     def next(self):
         if self._iter is None:
             v = it[0]
             yield (x, y, v)
             it.iternext()
+
+    def reset(self):
+        self._state = self.new_state(self._state.shape)
+        self._iter = None

gui.py

-import sys
-import pyglet
-import cgol
-
-game = None
-grid_w = None
-grid_h = None
-fps_display = pyglet.clock.ClockDisplay()
-batch = pyglet.graphics.Batch()
-window = pyglet.window.Window(resizable=True)
-
-
-@window.event
-def on_key_press(symbol, modifiers):
-    global grid_w
-    global grid_h
-    if symbol == pyglet.window.key.Q:
-        window.close()
-
-    if symbol == pyglet.window.key.F:
-        window.set_fullscreen(not (modifiers & pyglet.window.key.MOD_SHIFT))
-        grid_w = float(window.width) / game.state.shape[0]
-        grid_h = float(window.height) / game.state.shape[1]
-
-
-@window.event
-def on_resize(width, height):
-    global grid_w
-    global grid_h
-    grid_w = float(width) / game.state.shape[0]
-    grid_h = float(height) / game.state.shape[1]
-
-
-def update(dt):
-    global game
-    global batch
-
-    frame = game.next()
-
-    for x, y, v in frame:
-        top_left = (grid_w * x, grid_h * y)
-        top_right = (grid_w * (x + 1), grid_h * y)
-        bottom_left = (grid_w * x, grid_h * (y + 1))
-        bottom_right = (grid_w * (x + 1), grid_h * (y + 1))
-
-        batch.add(4, pyglet.gl.GL_QUADS,
-            None,
-            ('v2f', top_left + bottom_left + bottom_right + top_right),
-            ('c3f', (v, v, v) * 4)
-        )
-
-pyglet.clock.schedule(update)
-
-
-@window.event
-def on_draw():
-    window.clear()
-    batch.draw()
-    fps_display.draw()
-
-
-if __name__ == '__main__':
-    if len(sys.argv) == 3:
-        size = (sys.argv[1], sys.argv[2])
-    else:
-        size = None
-    global game
-    global grid_w
-    global grid_h
-    game = cgol.Game(size=map(int, size))
-    grid_w = float(window.width) / game.state.shape[0]
-    grid_h = float(window.height) / game.state.shape[1]
-
-    pyglet.app.run()
 numpy==1.6.2
 pyglet==1.1.4
 wsgiref==0.1.2
+git+https://onelson@bitbucket.org/onelson/golgui.git#egg=golgui