فهرست منبع

implemented initial scoring

Alexey Dorokhov 3 سال پیش
والد
کامیت
e1ab983620
1فایلهای تغییر یافته به همراه14 افزوده شده و 2 حذف شده
  1. 14 2
      game_state.py

+ 14 - 2
game_state.py

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