Advertisement
MRtecno98

Project Juno Source code V.1.2.2

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