ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Memorama Python


Enviado por   •  4 de Diciembre de 2019  •  Trabajo  •  2.507 Palabras (11 Páginas)  •  1.067 Visitas

Página 1 de 11

import random

def juegomemorama():

def card1():

r1 = int(input("Renglón 1 = "))

c1 = int(input("Columna 1 = "))

if not(0 <= r1 <= 5) or not(0 <= c1 <=5):

print("Esta carta no existe, trate de nuevo")

return card1()

if " " + str(game[r1][c1]) == show[r1 + 1][c1 + 1] or str(game[r1][c1]) == show[r1 + 1][c1 + 1]:

print("Esa carta ya no esta disponible, trate de nuevo")

return card1()

else:

return(r1, c1)

def card2():

r2 = int(input("Renglón 2 = "))

c2 = int(input("Columna 2 = "))

if not(0 <= r2 <= 5) or not(0 <= c2 <=5):

print("Esta carta no existe, trate de nuevo")

return card2()

if " " + str(game[r2][c2]) == show[r2 + 1][c2 + 1] or str(game[r2][c2]) == show[r2 + 1][c2 + 1]:

print("Esa carta ya no esta disponible, trate de nuevo")

return card2()

else:

if r1 == r2 and c1 == c2:

print("No puedes repetir carta, trate de nuevo")

return card2()

else:

return(r2, c2)

def cont():

conti = input("¿Quieres seguir jugando s/n? ")

if (conti != 's' and conti != 'n'):

print("s o n?")

return cont()

else:

if conti == 'n':

print("Puntos del jugador 1: " + str(player1score))

print("Puntos del jugador 2: " + str(player2score))

return(True)

elif conti == 's':

return(False)

def gameboard():

num = [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18]

random.shuffle(num)

col = 0

game = [[0,0,0,0,0,0],

[0,0,0,0,0,0],

[0,0,0,0,0,0],

[0,0,0,0,0,0],

[0,0,0,0,0,0],

[0,0,0,0,0,0]]

for number in num:

if col < 6:

game[0][col] = number

elif 6 <= col < 12:

game[1][col-6] = number

elif 12 <= col < 18:

game[2][col-12] = number

elif 18 <= col < 24:

game[3][col-18] = number

elif 24 <= col < 30:

game[4][col-24] = number

else:

game[5][col-30] = number

col += 1

return game

game=gameboard()

show = [[" "," 0"," 1"," 2"," 3"," 4"," 5"],

["0"," -"," -"," -"," -"," -"," -"],

["1"," -"," -"," -"," -"," -"," -"],

["2"," -"," -"," -"," -"," -"," -"],

["3"," -"," -"," -"," -"," -"," -"],

["4"," -"," -"," -"," -"," -"," -"],

["5"," -"," -"," -"," -"," -"," -"]]

for i in range(len(show)):

for u in range(len(show[i])):

print("", show[i][u],end="") #quita las ""

print("\n")

player1score = 0

player2score = 0

gamechip = 1

p = 1

while gamechip == 1:

if p == 1:

print("Es el turno al jugador 1")

elif p == 2:

print("Es el turno al jugador 2")

r1, c1 = card1()

print(game[r1][c1])

r2, c2 = card2()

print(game[r2][c2])

if game[r1][c1] == game[r2][c2]:

if len(str(game[r1][c1])) == 1:

show[r1

...

Descargar como (para miembros actualizados) txt (7 Kb) pdf (37 Kb) docx (11 Kb)
Leer 10 páginas más »
Disponible sólo en Clubensayos.com