-
-
Save parzibyte/7d81b6fd73a999c3ff441f6543c67274 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jugador_vs_computadora(tablero): | |
global ESTA_JUGANDO_CPU | |
ESTA_JUGANDO_CPU = True | |
jugador_actual = elegir_jugador_al_azar() | |
while True: | |
imprimir_tablero(tablero) | |
imprimir_tiradas_faltantes(tablero) | |
if jugador_actual == JUGADOR_1: | |
columna = imprimir_y_solicitar_turno(jugador_actual, tablero) | |
else: | |
print("CPU pensando...") | |
columna = obtener_columna_segun_cpu(jugador_actual, tablero) | |
pieza_colocada = colocar_pieza(columna, jugador_actual, tablero) | |
if not pieza_colocada: | |
print("No se puede colocar en esa columna") | |
ha_ganado = comprobar_ganador(jugador_actual, tablero) | |
if ha_ganado: | |
imprimir_tablero(tablero) | |
felicitar_jugador(jugador_actual) | |
break | |
elif es_empate(tablero): | |
imprimir_tablero(tablero) | |
indicar_empate() | |
break | |
else: | |
if jugador_actual == JUGADOR_1: | |
jugador_actual = JUGADOR_2 | |
else: | |
jugador_actual = JUGADOR_1 | |
ESTA_JUGANDO_CPU = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment