-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
56 lines (48 loc) · 1.42 KB
/
app.py
File metadata and controls
56 lines (48 loc) · 1.42 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
@author: Diksha Verma
"""
from gameoflife import Life
import numpy as np
l = Life()
patterns = l.lstPatterns()
print("_______________________________________________________________________________")
print("-------------------W E L C O M E To The Game Of Life---------------------------")
print("_______________________________________________________________________________")
print("==M E N U==")
print("1.View list of available patterns")
print("2.Show the board of pattern name")
print("3.Enter pattern name to start the game")
print("4.exit - to exit from game")
def lst():
for k in patterns.keys():
print(k)
def view_pattern(pat):
if pat not in patterns:
print("Invalid pattern_name")
else:
print(np.array(patterns[pat], dtype=np.uint8))
def iterations(n):
for i in range(int(n)):
print("\n>>{}:".format(i+1))
l.applyRule()
print(l.get_board())
def select_pattern(pat):
if not l.select(pat):
print("No pattern called {} exists!".format(pat))
else:
n=input("Enter number of iterations\n")
iterations(n)
while True:
choice = input("Your Choice (1-4)?\n")
if choice == "1":
lst()
elif choice == "2":
pat=input("Enter pattern name\n")
view_pattern(pat)
elif choice == "3":
pat=input("Enter board pattern\n")
select_pattern(pat)
elif choice == "4":
exit()
else:
print("Invalid input\n")