Browse Source

Write checkDiagonalRL function

main^2
fdai7726 11 months ago
committed by Peter Wiebe
parent
commit
034fac69d0
  1. 15
      src/main/c/VierGewinnt.c

15
src/main/c/VierGewinnt.c

@ -202,6 +202,21 @@ int checkDiagonalLR(char board[ROWS][COLS], char player) {
// Write checkDiagonalRL function
int checkDiagonalRL(char board[ROWS][COLS], char player) {
for (int row = 0; row <= ROWS - 4; row++) {
for (int col = 3; col < COLS; col++) {
if (board[row][col] == player &&
board[row + 1][col - 1] == player &&
board[row + 2][col - 2] == player &&
board[row + 3][col - 3] == player) {
return 1; // Gewonnen
}
}
}
return 0;
}
Loading…
Cancel
Save