-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_state.py
43 lines (30 loc) · 884 Bytes
/
gen_state.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
from pieces import *
import subprocess as sp
import time
def mapl(x,y):
return list(map(x,y))
width, height = (10, 20)
board = [[False] * width for _ in range(height)]
def show_board(b):
for i in range(height):
raw_row = b[-i]
row = mapl(lambda x: 'o' if x else '.', raw_row)
print("".join(row))
def copy_board(b):
return [bb[:] for bb in b]
ox, oy = (5, 16)
def check_collision(b,x,y,o):
def drop_piece(p, x, y, o):
return (x,y,o)
def gen_states(b, p):
for piece_id in "JIZLOTS":
cur_piece = rotation_table[piece_id]
for i in range(8):
orient_piece = cur_piece[i % 4]
temp_board = copy_board(board)
for cell in orient_piece:
print(cell)
temp_board[oy + cell[0]][ox + cell[1]] = True
show_board(temp_board)
time.sleep(0.5)
sp.call('clear',shell=True)