Skip to content

Instantly share code, notes, and snippets.

@gollum23
Created January 21, 2016 19:52
Show Gist options
  • Select an option

  • Save gollum23/758b079abd90a51720c7 to your computer and use it in GitHub Desktop.

Select an option

Save gollum23/758b079abd90a51720c7 to your computer and use it in GitHub Desktop.
Juego de piedra papel o tijera con verbos
#!/usr/bin/env python
# -*-coding:utf-8-*-
import time
from time import sleep
import random
sus="-"*35
action = ""
win = True
depo=["piedra","papel","tijera", "lagarto", "spock"]
while True:
x=raw_input("piedra, papel, tijera, lagarto, spock, \
'salir' si quieres terminar: ")
if x != "salir" and x not in depo:
print ("No hagas trampa!")
continue
if x == "salir":
exit()
pc=random.choice(depo)
sleep(0.5)
print (("Computadora elijio {}.").format(pc))
if x==pc:
sleep(0.5)
print (("\nEmpate.\n{}").format(sus))
elif x=="piedra":
if pc=="tijera":
win = True
action = "aplasta"
elif pc=="lagarto":
win = True
action = "aplasta"
elif pc=="papel":
win = False
action = "tapa"
elif pc=="spock":
win = False
action = "vaporiza"
elif x=="papel":
if pc=="piedra":
win = True
action = "tapa"
elif pc=="spock":
win = True
action = "desautoriza"
elif pc=="lagarto":
win = False
action = "devora"
elif pc=="tijera":
win = False
action = "corta"
elif x=="tijera":
if pc=="papel":
win = True
action = "corta"
elif pc=="lagarto":
win = True
action = "decapita"
elif pc=="spock":
win = False
action = "rompe"
elif pc=="piedra":
win = False
action = "aplasta"
elif x=="lagarto":
if pc =="spock":
win = True
action = "envenena"
elif pc =="papel":
win = True
action = "devora"
elif pc=="tijeras":
win = False
action = "decapita"
elif pc=="piedra":
win = False
action = "aplasta"
elif x=="spock":
if pc=="tijeras":
win = True
action="rompe"
elif pc=="piedra":
win = True
action="vaporiza"
elif pc=="lagarto":
win = False
action = "envenena"
elif pc=="papel":
win = False
action = "desautoriza"
sleep(0.5)
if win:
print (("\nGanaste. {} {} {}\n{}").format(x, action, pc, sus))
else:
print (("\Perdiste. {} {} {}\n{}").format(pc, action, x, sus))
input()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment