-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_cli.py
49 lines (44 loc) · 1.12 KB
/
run_cli.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import time
import os
from GameRules import GameRules
TOTAL_CELLS = 25
dx = int(TOTAL_CELLS/2)
initial = [(dx, dx+1), (dx, dx+2), (dx+1, dx+1), (dx+1, dx+1), (dx+2, dx+1)]
G = GameRules(initial, TOTAL_CELLS)
G.initialise_plateau()
def play():
G.update_cells()
G.update_plateau()
return G.get_plateau()
def imprime_plateau(plateau):
out = ''
for e in plateau:
out = out+str(e)+'\n'
return out
os.system('cls||clear')
print('Initialisation')
print(f'Stat Cellule : Morte 0, Naissance 0')
print(imprime_plateau(G.get_plateau()))
time.sleep(1)
os.system('cls||clear')
iter=0
started = True
while started:
p = play()
u = imprime_plateau(p)
dead = G.get_death_cells()
birth = G.get_birth_cells()
survived = G.get_survived_cells()
if len(birth) == 0 and len(dead) == 0:
started = False
else:
iter += 1
print(f'Iter {iter}')
print(f'Stat Cells : Dead {len(dead)}, Birth {len(birth)}, Survived {len(survived)}')
print(u)
time.sleep(0.7)
if started:
os.system('clear||cls')
else:
print(f'Stable structure after {iter} iteration(s)')
exit (0)