Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 12, 2020 01:07
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/d0c5212385a3dbbbd9a513f2017a1800 to your computer and use it in GitHub Desktop.
Save parzibyte/d0c5212385a3dbbbd9a513f2017a1800 to your computer and use it in GitHub Desktop.
/*
____ _____ _ _ _
| _ \ | __ \ (_) | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___|
__/ | __/ |
|___/ |___/
____________________________________
/ Si necesitas ayuda, contáctame en \
\ https://parzibyte.me /
------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Creado por Parzibyte (https://parzibyte.me). Este encabezado debe mantenerse intacto,
excepto si este es un proyecto de un estudiante.
*/
#include "conecta4.h"
#include <stdlib.h> // rand y RAND_MAX
char obtenerOponente(char jugador) {
if (jugador == JUGADOR_1) {
return JUGADOR_2;
} else {
return JUGADOR_1;
}
}
int aleatorio_en_rango(int minimo, int maximo) {
return minimo + rand() / (RAND_MAX / (maximo - minimo + 1) + 1);
}
char elegirJugadorAlAzar() {
int numero = aleatorio_en_rango(0, 1);
if (numero) {
return JUGADOR_1;
} else {
return JUGADOR_2;
}
}
int solicitarColumnaAJugador() {
int columna = 0;
printf("Escribe la columna en donde colocar la pieza: ");
scanf("%d", &columna);
// Necesitamos índices de arreglos
columna--;
return columna;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment