-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (29 loc) · 937 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import argparse
from time import sleep
from game_manager import GameManager
def build_args():
parser = argparse.ArgumentParser('Run Conway\'s Game of Life')
parser.add_argument('--load-txt', type=str)
parser.add_argument('--load-bin', type=str)
parser.add_argument('--save-init-txt', type=str)
parser.add_argument('--save-init-bin', type=str)
return parser.parse_args()
if __name__ == '__main__':
args = build_args()
if args.load_txt:
game = GameManager(from_file=args.load_txt)
elif args.load_bin:
game = GameManager.load_bin(args.load_bin)
else:
game = GameManager()
if args.save_init_txt:
game.save_txt(args.save_init_txt)
if args.save_init_bin:
game.save_bin(args.save_init_bin)
try:
while True:
game.draw()
game.update()
sleep(0.3)
except KeyboardInterrupt:
print('\nGood Bye!')