|
@@ -110,6 +110,7 @@ class GameState:
|
|
|
score=self.data.score)
|
|
score=self.data.score)
|
|
|
|
|
|
|
|
try_game_state = GameState()
|
|
try_game_state = GameState()
|
|
|
|
|
+ drop_count = 0
|
|
|
while True:
|
|
while True:
|
|
|
try_game_state.data = GameStateData(
|
|
try_game_state.data = GameStateData(
|
|
|
grid=next_game_state.data.grid,
|
|
grid=next_game_state.data.grid,
|
|
@@ -121,8 +122,17 @@ class GameState:
|
|
|
score=next_game_state.data.score)
|
|
score=next_game_state.data.score)
|
|
|
if try_game_state.is_valid():
|
|
if try_game_state.is_valid():
|
|
|
next_game_state.data = try_game_state.data
|
|
next_game_state.data = try_game_state.data
|
|
|
|
|
+ drop_count += 1
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
+ next_game_state.data = GameStateData(
|
|
|
|
|
+ grid=next_game_state.data.grid,
|
|
|
|
|
+ current_piece=next_game_state.data.current_piece,
|
|
|
|
|
+ next_piece=next_game_state.data.next_piece,
|
|
|
|
|
+ rotation=next_game_state.data.rotation,
|
|
|
|
|
+ row=next_game_state.data.row,
|
|
|
|
|
+ col=next_game_state.data.col,
|
|
|
|
|
+ score=next_game_state.data.score + drop_count*2)
|
|
|
return next_game_state
|
|
return next_game_state
|
|
|
|
|
|
|
|
def _advance_down(self):
|
|
def _advance_down(self):
|
|
@@ -160,14 +170,16 @@ class GameState:
|
|
|
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.byte, order="C")
|
|
dtype=np.byte, order="C")
|
|
|
- next_score = self.data.score
|
|
|
|
|
|
|
+ lines_purged = 0
|
|
|
for row in range(FIELD_HEIGHT-1, -1,-1):
|
|
for row in range(FIELD_HEIGHT-1, -1,-1):
|
|
|
if np.all(self.data.grid[row,:]):
|
|
if np.all(self.data.grid[row,:]):
|
|
|
- next_score += 1
|
|
|
|
|
|
|
+ lines_purged += 1
|
|
|
else:
|
|
else:
|
|
|
next_grid[next_grid_row,:] = self.data.grid[row,:]
|
|
next_grid[next_grid_row,:] = self.data.grid[row,:]
|
|
|
next_grid_row -= 1
|
|
next_grid_row -= 1
|
|
|
|
|
|
|
|
|
|
+ lines_scores = [0, 40, 100, 300, 1200]
|
|
|
|
|
+ next_score = self.data.score + lines_scores[lines_purged]
|
|
|
next_game_state = GameState()
|
|
next_game_state = GameState()
|
|
|
next_game_state.next_piece_func = self.next_piece_func
|
|
next_game_state.next_piece_func = self.next_piece_func
|
|
|
next_game_state.data = GameStateData(
|
|
next_game_state.data = GameStateData(
|