Skip to content

Instantly share code, notes, and snippets.

@gfhuertac
Created November 21, 2018 14:00
Show Gist options
  • Save gfhuertac/88600b595601bc23239864e237adb88e to your computer and use it in GitHub Desktop.
Save gfhuertac/88600b595601bc23239864e237adb88e to your computer and use it in GitHub Desktop.
import numpy
#Escribe verifica(matriz) acá
tablero = numpy.zeros([6,7], dtype=int)
turno = 1
while(verifica(tablero) == 0):
if tablero.all():
print("No hay ganadores")
exit()
while(True):
columna = int(input("Jugador " + str(turno) + " ingrese columna:"))
if columna < 1 or columna > tablero.shape[1]:
print("Columna inválida. Intente nuevamente")
elif tablero[:,columna-1].all():
print("Columna llena. Intente con otra")
else:
break
posicion = numpy.where(tablero[:,columna-1] != 0)
tablero[tablero.shape[0] - len(posicion[0]) - 1, columna-1] = turno
print(tablero)
turno = turno%2 + 1
print("Ha ganado el jugador", verifica(tablero))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment