Advertisement
MRtecno98

Project Juno Source code V.1.2.1

Dec 31st, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.39 KB | None | 0 0
  1. import random
  2. import time
  3. UName = ""
  4. z = 0
  5. name = "Juno" #Nome del'AI
  6. CurrentYear = 2016
  7. #Definisco un dizionario(o HashMap) per salvare domande e risposte
  8. x = {"Come ti chiami?" : "Mi chiamo " + name , "Quanti anni hai?" : "2 anni" , "Come stai?" : "Bene" , "Ciao " + name : "Ciao anche a te" , "Bravo "  + name : "Grazie!" , "Sai chi sono io?" : "Tu sei " + UName}
  9.  
  10.  
  11. def SCF() :
  12.     print("=========================================")
  13.     print("Sasso Carta Forbice remastered for Python")
  14.     print("      by NEGCommand & MRtecno98")
  15.     print("=========================================")
  16.     input("            Enter to start")
  17.  
  18.     print("\n\n\nInserire il numero di match(-1 per infinito)")
  19.     bo = 1
  20.     puntggutente = 0
  21.     puntggcomput = 0
  22.     while bo == 1:
  23.         try :
  24.             ms = int(input(">>> "))
  25.         except ValueError:
  26.             print("Inserisci un numero, non una lettera")
  27.         else:
  28.             bo = 0
  29.  
  30.     while ms != 0:
  31.         oggutente = input('\nInserisci un oggetto [Sasso|Carta|Forbice|Esci]: ')
  32.         oggcomp = random.randint(1, 3)
  33.    
  34.         if "E" in oggutente or oggutente == "Esci" :
  35.             break
  36.    
  37.         if oggutente == 'Sasso' or "s" in oggutente or "S" in oggutente or oggutente == "sasso":
  38.             if oggcomp == 1:
  39.                 print('[Tu:Sasso ','Pc:'+'Sasso]','  PAREGGIO')
  40.             elif oggcomp == 2:
  41.                 print('[Tu:Sasso ','Pc:'+'Carta]','  HAI PERSO')
  42.                 puntggcomput = puntggcomput + 1
  43.             elif oggcomp == 3:
  44.                 print('[Tu:Sasso ','Pc:'+'Forbice]','  HAI VINTO')
  45.                 puntggutente = puntggutente + 1
  46.             ms = ms - 1
  47.         elif oggutente == 'Carta' or "c" in oggutente or "C" in oggutente or oggutente == "carta":
  48.             if oggcomp == 1:
  49.                 print('[Tu:Carta ','Pc:'+'Sasso]','  HAI VINTO')
  50.                 puntggutente = puntggutente + 1
  51.             elif oggcomp == 2:
  52.                 print('[Tu:Carta ','Pc:'+'Carta]','  PAREGGIO')
  53.             elif oggcomp == 3:
  54.                 print('[Tu:Carta ','Pc:'+'Forbice]','  HAI PERSO')
  55.                 puntggcomput = puntggcomput + 1
  56.             ms = ms - 1
  57.         elif oggutente == 'Forbice' or "f" in oggutente or "F" in oggutente or oggutente == "forbice":
  58.             if oggcomp == 1:
  59.                 print('[Tu:Forbice ','Pc:'+'Sasso]','  HAI PERSO')
  60.                 puntggcomput = puntggcomput + 1
  61.             elif oggcomp == 2:
  62.                 print('[Tu:Forbice ','Pc:'+'Carta]','  HAI VINTO')
  63.                 puntggutente = puntggutente + 1
  64.             elif oggcomp == 3:
  65.                 print('[Tu:Forbice ','Pc:'+'Forbice]','  PAREGGIO')
  66.             ms = ms - 1
  67.         else:
  68.             print("Inserire un oggetto valido")
  69.  
  70.     if puntggutente > puntggcomput :
  71.         print("\nTOTALE: [Tu:" + str(puntggutente) + "  " + "Pc:" + str(puntggcomput) + "]" , "HAI VINTO!")
  72.  
  73.     if puntggutente < puntggcomput :
  74.         print("\nTOTALE: [Tu:" + str(puntggutente) + "  " + "Pc:" + str(puntggcomput) + "]" , "HAI PERSO!")
  75.  
  76.     if puntggutente == puntggcomput :
  77.         print("\nTOTALE: [Tu:" + str(puntggutente) + "  " + "Pc:" + str(puntggcomput) + "]" , "PAREGGIO")
  78.  
  79. while z <= 100 :
  80.     print("\n")
  81.     z = z + 1
  82. z = 0
  83. UName = input("Qual'è il tuo nome? ")
  84.  
  85. while z <= 100 :
  86.     print("\n")
  87.     z = z + 1
  88. z = 0
  89. print("Ciao, sono " + name + ", cosa mi vuoi dire?") #Messaggio di benvenuto
  90.  
  91. if time.strftime("%Y") == CurrentYear + 1 :
  92.     print("Buon " + time.strftime("%Y") + "!!!!")
  93.     CurrentYear = CurrentYear + 1
  94.  
  95. #While infinito per ciclare
  96. while True :
  97.     d = input(">>> ") #Faccio la domanda
  98.    
  99.     if d == "esci" or d == "Esci" :
  100.         input("Ciao, spero di rivederti!")
  101.         break
  102.  
  103.     if "giochiamo a sasso carta forbice" in d :
  104.         input("\nOk, ti batterò di sicuro ;)\n")
  105.         SCF()
  106.         print("\nBella giocata eh?")
  107.         continue
  108.    
  109.     if "Quanto fa" in d and "*" in d :
  110.         d = d.replace(" " , "")
  111.         num1 = int(d[8])
  112.         num2 = int(d[10])
  113.         risu = num1 * num2
  114.         print(num1 , "*" , num2 , "fa" , risu)
  115.         continue
  116.    
  117.     if "che ora è" in d or "Che ora è" in d :
  118.         print("In questo momento l'ora esatta è:")
  119.         print(time.strftime("%c"))
  120.         continue
  121.    
  122.     if "Quanto fa" in d and "+" in d :
  123.         d = d.replace(" " , "")
  124.         num1 = int(d[8])
  125.         num2 = int(d[10])
  126.         risu = num1 + num2
  127.         print(num1 , "+" , num2 , "fa" , risu)
  128.         continue
  129.    
  130.     if "Quanto fa" in d and "-" in d :
  131.         d = d.replace(" " , "")
  132.         num1 = int(d[8])
  133.         num2 = int(d[10])
  134.         risu = num1 - num2
  135.         print(num1 , "-" , num2 , "fa" , risu)
  136.         continue
  137.    
  138.     if "Quanto fa" in d and "/" in d :
  139.         d = d.replace(" " , "")
  140.         num1 = int(d[8])
  141.         num2 = int(d[10])
  142.         risu = num1 / num2
  143.         print(num1 , "/" , num2 , "fa" , risu)
  144.         continue
  145.    
  146.     if "pulisci" in d :
  147.         while z <= 100 :
  148.             print("\n")
  149.             z = z + 1
  150.         z = 0
  151.         continue
  152.    
  153.     if d in x :   #Controllo se è stata già fatta e registrata
  154.         print(x[d]) #Se sì stampo la risposta
  155.     else :  #Se no
  156.         print("Non ho capito, cosa devo rispondere?")
  157.         a = input(">>> ") #Chiedo all'utente cosa rispondere
  158.         if a != "niente" :
  159.             x[d] = a #E lo memorizzo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement