|
@@ -23,17 +23,17 @@ def tetromino_to_field_at(tetromino, row, col):
|
|
|
|
|
|
|
|
array = tetromino.data
|
|
array = tetromino.data
|
|
|
left_zeros = np.zeros(shape=(array.shape[0], col_offset),
|
|
left_zeros = np.zeros(shape=(array.shape[0], col_offset),
|
|
|
- dtype=np.int32, order="C")
|
|
|
|
|
|
|
+ dtype=np.byte, order="C")
|
|
|
right_zeros = np.zeros(shape=(array.shape[0],
|
|
right_zeros = np.zeros(shape=(array.shape[0],
|
|
|
FIELD_WIDTH-col_offset-array.shape[1]),
|
|
FIELD_WIDTH-col_offset-array.shape[1]),
|
|
|
- dtype=np.int32, order="C")
|
|
|
|
|
|
|
+ dtype=np.byte, order="C")
|
|
|
array = np.concatenate((left_zeros, array, right_zeros), axis=1)
|
|
array = np.concatenate((left_zeros, array, right_zeros), axis=1)
|
|
|
|
|
|
|
|
top_zeros = np.zeros(shape=(row_offset,FIELD_WIDTH),
|
|
top_zeros = np.zeros(shape=(row_offset,FIELD_WIDTH),
|
|
|
- dtype=np.int32, order="C")
|
|
|
|
|
|
|
+ dtype=np.byte, order="C")
|
|
|
bottom_zeros = np.zeros(shape=(FIELD_HEIGHT - row_offset - array.shape[0],
|
|
bottom_zeros = np.zeros(shape=(FIELD_HEIGHT - row_offset - array.shape[0],
|
|
|
FIELD_WIDTH),
|
|
FIELD_WIDTH),
|
|
|
- dtype=np.int32, order="C")
|
|
|
|
|
|
|
+ dtype=np.byte, order="C")
|
|
|
array = np.concatenate((top_zeros, array, bottom_zeros), axis=0)
|
|
array = np.concatenate((top_zeros, array, bottom_zeros), axis=0)
|
|
|
return array
|
|
return array
|
|
|
|
|
|
|
@@ -45,7 +45,7 @@ GameState = collections.namedtuple('GameState',
|
|
|
|
|
|
|
|
def initial_game_state(current_piece, next_piece):
|
|
def initial_game_state(current_piece, next_piece):
|
|
|
return GameState(grid=np.zeros(shape=(FIELD_HEIGHT,FIELD_WIDTH),
|
|
return GameState(grid=np.zeros(shape=(FIELD_HEIGHT,FIELD_WIDTH),
|
|
|
- dtype=np.int32, order="C"),
|
|
|
|
|
|
|
+ dtype=np.byte, order="C"),
|
|
|
current_piece=current_piece,
|
|
current_piece=current_piece,
|
|
|
next_piece=next_piece,
|
|
next_piece=next_piece,
|
|
|
rotation=0, row=0, col=0, score=0)
|
|
rotation=0, row=0, col=0, score=0)
|
|
@@ -144,7 +144,7 @@ def advance_game_state_piece(game_state, next_piece):
|
|
|
def advance_game_state_purge_lines(game_state):
|
|
def advance_game_state_purge_lines(game_state):
|
|
|
next_grid_row = FIELD_HEIGHT-1
|
|
next_grid_row = FIELD_HEIGHT-1
|
|
|
next_grid = np.zeros(shape=(FIELD_HEIGHT,FIELD_WIDTH),
|
|
next_grid = np.zeros(shape=(FIELD_HEIGHT,FIELD_WIDTH),
|
|
|
- dtype=np.int32, order="C")
|
|
|
|
|
|
|
+ dtype=np.byte, order="C")
|
|
|
next_score = game_state.score
|
|
next_score = game_state.score
|
|
|
for row in range(FIELD_HEIGHT-1, -1,-1):
|
|
for row in range(FIELD_HEIGHT-1, -1,-1):
|
|
|
if np.all(game_state.grid[row,:]):
|
|
if np.all(game_state.grid[row,:]):
|