Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 21, 2021 18:40
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/8bb17e4b84e6db48aa9a10da4b592d5f to your computer and use it in GitHub Desktop.
Save parzibyte/8bb17e4b84e6db48aa9a10da4b592d5f to your computer and use it in GitHub Desktop.
// Imprime algo que el CPU "dice"
static void hablar(String mensaje, char jugador) {
System.out.printf("\nCPU (%c) dice: %s\n\n", jugador, mensaje);
}
// Debería llamarse después de verificar si alguien gana
// Indica si hay un empate
static boolean empate(char[][] tableroOriginal) {
int y;
for (y = 0; y < FILAS; y++) {
int x;
for (x = 0; x < COLUMNAS; x++) {
// Si hay al menos un espacio vacío se dice que no hay empate
if (tableroOriginal[y][x] == ESPACIO_VACIO) {
return false;
}
}
}
return true;
}
// Devuelve un número aleatorio en un rango, incluyendo los límites
public static int aleatorioEnRango(int minimo, int maximo) {
// nextInt regresa en rango pero con límite superior exclusivo, por eso sumamos 1
return ThreadLocalRandom.current().nextInt(minimo, maximo + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment