Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 21, 2021 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/99538cf5da68fefeca5535ba61396a23 to your computer and use it in GitHub Desktop.
Save parzibyte/99538cf5da68fefeca5535ba61396a23 to your computer and use it in GitHub Desktop.
// Devuelve las coordenadas en las que se puede ganar, o -1 y -1 si no se puede ganar
static int[] coordenadasParaGanar(char jugador, char[][] tableroOriginal) {
int y, x;
for (y = 0; y < FILAS; y++) {
for (x = 0; x < COLUMNAS; x++) {
char[][] copiaTablero = clonarMatriz(tableroOriginal);
if (coordenadasVacias(y, x, copiaTablero)) {
colocarPieza(y, x, jugador, copiaTablero);
if (comprobarSiGana(jugador, copiaTablero)) {
return new int[]{x, y};
}
}
}
}
return new int[]{-1, -1};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment