Skip to content

Commit

Permalink
looping option added
Browse files Browse the repository at this point in the history
  • Loading branch information
iiSeymour committed May 21, 2016
1 parent b9c7bd5 commit e2e4ba8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ A python implementation of [Conway's Game of Life](http://en.wikipedia.org/wiki/

```
$ gol --help
sage: gol.py [-h] [-a] [-f] [-n initial_points] [-r refresh_rate] [-t] [-x] [-v]
usage: gol.py [-h] [-a] [-l] [-f] [-n initial_points] [-r refresh_rate] [-t] [-x] [-v]
optional arguments:
-h, --help show this help message and exit
-a, --autostart skip the splash screen
-l, --loop immediately restart game
-f, --fullscreen display fullscreen grid
-n initial_points set the number of initial points
-r refresh_rate set the refresh rate
Expand Down
9 changes: 8 additions & 1 deletion conway/gol.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from time import sleep
from itertools import chain, product

__version_info__ = (1, 0, 1)
__version_info__ = (1, 0, 2)
__version__ = ".".join(map(str, __version_info__))


class gol(object):

def __init__(self, args):
self.test = args.test
self.loop = args.loop
self.screen = curses.initscr()
self.screen.keypad(1)
self.initCurses()
Expand Down Expand Up @@ -288,6 +289,10 @@ def end(self):
"""
Game Finished - Restart or Quit
"""
if self.loop:
self.restart
return

self.addstr(2, self.x_grid / 2 - 4, "GAMEOVER", 7)

if self.hud:
Expand All @@ -309,6 +314,8 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--autostart", action="store_true",
default=False, help="skip the splash screen")
parser.add_argument("-l", "--loop", action="store_true",
default=False, help="immediately restart game")
parser.add_argument("-f", "--fullscreen", action="store_true",
default=False, help="display fullscreen grid")
parser.add_argument("-n", type=int, metavar="initial_points",
Expand Down

0 comments on commit e2e4ba8

Please sign in to comment.