-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_game.py
39 lines (33 loc) · 1.01 KB
/
cli_game.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
from game import SnakeGame
from os import system,name
import matplotlib.pyplot as plt
from array2gif import write_gif
import sys
from matplotlib.animation import ArtistAnimation as AA
def clear():
##Thanks stackoverflow
# for windows
if name == 'nt':
_ = system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
if __name__=='__main__':
game=SnakeGame((9,9),walls=True)
clear()
while (True):
print(game.get_board())
plt.imshow(game.render())
plt.show()
move=input("Move:\n")
if move=='exit':
sys.exit(0)
move=int(move)
if move in range(4):
_,_,done,_=game.step(move)
if done:
#fig=plt.figure()
#anim=AA(fig,[[plt.imshow(i)] for i in game.board_store])
#anim.save('cli_game.gif')
break
print(done)