feat: Adjust board traversal logic for active player direction

- Update board traversal logic to handle direction based on active player
  Introduce `startRow` and `rowDir` for flexible iteration, adjusting row iteration logic to vary starting points and directions based on whether the active player is Black.

[board/move.go]
- Added logic to handle board traversal direction based on the active player, introducing `startRow` and `rowDir` for flexible iteration.
- Adjusted the row iteration logic to account for varying starting points and directions, depending on whether the active player is Black.
- No changes were made to the underlying move generation or legality checks.
This commit is contained in:
MSWS
2025-03-23 17:20:15 -07:00
parent 3739104149
commit 6ce23992ae

View File

@@ -249,7 +249,14 @@ func (game Game) GetMoves() []Move {
board := game.Board
pieces := 0
for row := 0; row < len(board) && pieces < 16; row++ {
startRow := 0
rowDir := 1
if game.Active == Black {
startRow = 7
rowDir = -1
}
for row := startRow; row < len(board) && row >= 0 && pieces < 16; row += rowDir {
for col := 0; col < len(board[row]) && pieces < 16; col++ {
piece := board[row][col]