mirror of
https://github.com/kristoferssolo/2048.git
synced 2025-10-21 15:20:35 +00:00
feat(game): add _push_board_right
This commit is contained in:
parent
ec134ffba7
commit
05d5e90dde
@ -95,3 +95,16 @@ class Game2048:
|
||||
for val in row:
|
||||
print(f"{val:^3}", end="")
|
||||
print()
|
||||
|
||||
def _push_board_right(self) -> tuple[np.ndarray, bool]:
|
||||
new = np.zeros((self.size, self.size), dtype=int)
|
||||
done = False
|
||||
for row in range(self.size):
|
||||
count = self.size - 1
|
||||
for col in range(self.size - 1, -1, -1):
|
||||
if self.board[row, col] != 0:
|
||||
new[row, count] = self.board[row, col]
|
||||
if col != count:
|
||||
done = True
|
||||
count -= 1
|
||||
return new, done
|
||||
|
||||
Loading…
Reference in New Issue
Block a user