# Untitled

unknown
plain_text
2 months ago
2.3 kB
1
Indexable
Never
```import random
import time

def draw_board(board):
print("|", board[0], "|", board[1], "|", board[2], "|", board[3], "|")
print("|", board[4], "|", board[5], "|", board[6], "|", board[7], "|")
print("|", board[8], "|", board[9], "|", board[10], "|", board[11], "|")
print("|", board[12], "|", board[13], "|", board[14], "|", board[15], "|")
print("|", board[16], "|", board[17], "|", board[18], "|", board[19], "|")
print("|", board[20], "|", board[21], "|", board[22], "|", board[23], "|")
print("|", board[24], "|", board[25], "|", board[26], "|", board[27], "|")
print("|", board[28], "|", board[29], "|", board[30], "|", board[31], "|")
print("|", board[32], "|", board[33], "|", board[34], "|", board[35], "|")
print("|", board[36], "|", board[37], "|", board[38], "|", board[39], "|")

def create_piece():
shape = random.randint(1, 7)
if shape == 1: # straight
orientation = random.randint(1, 2)
if orientation == 1:
piece = [[1, 1, 1, 1]]
else:
piece = [[1], [1], [1], [1]]
elif shape == 2: # right-angle
orientation = random.randint(1, 4)
if orientation == 1:
piece = [[0, 1, 0], [1, 1, 1], [0, 0, 0]]
elif orientation == 2:
piece = [[0, 0, 0], [1, 1, 1], [0, 1, 0]]
elif orientation == 3:
piece = [[0, 0, 0], [1, 1, 1], [1, 0, 0]]
else:
piece = [[1, 1, 1], [0, 1, 0], [0, 0, 0]]
elif shape == 3: # L-shape
orientation = random.randint(1, 4)
if orientation == 1:
piece = [[0, 1, 0], [0, 1, 1], [0, 0, 0]]
elif orientation == 2:
piece = [[0, 0, 0], [1, 1, 1], [0, 1, 0]]
elif orientation == 3:
piece = [[0, 0, 0], [1, 1, 1], [1, 0, 0]]
else:
piece = [[1, 1, 1], [1, 0, 0], [0, 0, 0]]
elif shape == 4: # box
piece = [[1, 1], [1, 1]]
elif shape == 5: # inverted L-shape
orientation = random.randint(1, 4)
if orientation == 1:
piece = [[0, 0, 0], [1, 1, 1], [1, 1, 0]]
elif orientation == 2:
piece = [[0, 1, 0], [0, 1, 1], [0, 0, 0]]
elif orientation == 3:
piece = [[0, ```