CSCI 152- Java
I created a class goBoard_SFry with methods for turn-taking, board rendering,
capture logic, and scoring. Recursion is used to:
hasLiberty)removeGroup)countTerritory)Note: Suicide moves are currently not prevented — stones placed in captured areas without liberties can survive. Scoring works, but may count those cases incorrectly.
public void placePiece() {
if (!gameOn) return;
int playerColor = currentPlayer.equals("black(X)") ? 1 : 2;
int opponentColor = playerColor == 1 ? 2 : 1;
board[moveY][moveX] = playerColor;
for (int[] dir : directions) {
int ny = moveY + dir[0];
int nx = moveX + dir[1];
if (ny >= 0 && ny < boardSize && nx >= 0 && nx < boardSize && board[ny][nx] == opponentColor) {
boolean[][] visited = new boolean[boardSize][boardSize];
if (!hasLiberty(ny, nx, opponentColor, visited)) {
removeGroup(ny, nx, opponentColor);
}
}
}
}
This project helped me understand recursive group traversal and territory control logic in Go. Handling edge cases like suicide moves and correct scoring requires further refinement.