Refactoring to use numpy. /JL

This commit is contained in:
2025-05-04 20:56:01 +02:00
parent 431dfcc4d7
commit c443df22ef
6 changed files with 154 additions and 19 deletions

View File

@@ -1,22 +1,33 @@
import numpy as np
def init():
global BRICKS
BRICKS = [
[[0,1,0], [1,1,1], [0,1,0]],
[[0, 0, 1], [1, 1, 1]],
[[1, 0, 0], [1, 1, 1]],
[[1]],
[[1, 1, 1, 1]],
[[1, 1], [1, 1]],
[[0, 1, 1], [1, 1, 0]],
[[1, 1, 0], [0, 1, 1]],
[[1, 0, 1], [1, 1, 1]],
[[1, 1, 1], [0, 1, 0]]
]
BRICKS = {
'I': np.array([[1, 1, 1, 1]]),
'O': np.array([[1, 1],
[1, 1]]),
'T': np.array([[0, 1, 0],
[1, 1, 1]]),
'S': np.array([[0, 1, 1],
[1, 1, 0]]),
'Z': np.array([[1, 1, 0],
[0, 1, 1]]),
'J': np.array([[1, 0, 0],
[1, 1, 1]]),
'L': np.array([[0, 0, 1],
[1, 1, 1]]),
'.': np.array([[1]]),
'+': np.array([[0, 1, 0],
[1, 1, 1],
[0, 1, 0]]),
'U': np.array([[1, 0, 1],
[1, 1, 1]])
}
global TILE_SIZE
TILE_SIZE = 48
global GRID_WIDTH
GRID_WIDTH = 10
global GRID_HEIGHT
GRID_HEIGHT = 18
global dropgrid
dropgrid = [[0 for _ in range(GRID_WIDTH)] for _ in range(GRID_HEIGHT)]
global grid
grid = np.zeros((GRID_HEIGHT, GRID_WIDTH), dtype=int)