-
Notifications
You must be signed in to change notification settings - Fork 0
/
play_human.py
40 lines (28 loc) · 960 Bytes
/
play_human.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
"""Optional file to play tetris yourself.
Run it as,
python play_human.py --rows 20 --columns 10
"""
from gui import GUI
from tests import tests
try:
from absl import flags
from absl import app
except ModuleNotFoundError:
print("Hey! absl was not found. Did you run `pip install -r requirements.txt` ?")
exit()
flags.DEFINE_integer("rows", 20, "Number of rows in this game.")
flags.DEFINE_integer("columns", 10, "Number of columns in this game.")
flags.DEFINE_integer("test", -1, "Test sequence to load, -1 is random.")
FLAGS = flags.FLAGS
def main(argv):
sequence = None
rows = FLAGS.rows
columns = FLAGS.columns
if FLAGS.test != -1:
rows, columns, _, sequence = tests[FLAGS.test]
gui = GUI(rows, columns, sequence=sequence)
gui.print_instructions()
while gui.running:
gui.update(human_input=True)
if __name__ == "__main__":
app.run(main)