|
@@ -1,11 +1,28 @@
|
|
|
from GameOfLifeLibrary import GameOfLife
|
|
|
import sys
|
|
|
+import argparse
|
|
|
|
|
|
-sys.stdin = open("a.txt")
|
|
|
+parser = argparse.ArgumentParser()
|
|
|
+parser.add_argument("--file", help="File to read. Default is stdin", default='stdin')
|
|
|
|
|
|
-sizex, sizey, gens = (int(i) for i in input().split())
|
|
|
+args = parser.parse_args()
|
|
|
+
|
|
|
+use_prompt = False
|
|
|
+
|
|
|
+if not args.file == 'stdin':
|
|
|
+ sys.stdin = open(args.file, 'r')
|
|
|
+else:
|
|
|
+ use_prompt = True
|
|
|
+
|
|
|
+sizex, sizey, gens = (int(i) for i in input('Enter width, height and number '
|
|
|
+ 'of gens splitted by whitespaces: '
|
|
|
+ if use_prompt else ''
|
|
|
+ ).split())
|
|
|
|
|
|
a = GameOfLife(sizex, sizey)
|
|
|
+
|
|
|
+print('Enter field (and after that use Ctrl+D to stop input stream): ')
|
|
|
+
|
|
|
a.parse_field([line[:-1] if line[-1] == '\n' else line for line in sys.stdin.readlines()])
|
|
|
|
|
|
for i in range(gens):
|