2016-09-18 6 views
-4

私のAI私はwhileループで作品を作っていますが、すべてのためのステートメントは、私はそれが例えば言いたい場合は、次のとおりです。whileループ内のif文を使用したAIの複数入力会話は機能しませんか?

`while 1: 



lis = ("im bored","game","im board","what do you want to do","what should we do","rage","i","I","smashed","broke","destroyed","cracked","grounded","detention","in trouble","nothing","not much","erics number","date","time","no","nope","nah","not","yes","yep","yeah","in deed","bye","gtg","got to go","see you","c u","hi","hello","hello","hia","fuck","crap","shit","bleep","omg","OMG","oh my god","","","","","","look up","email","map","add Note","get Note","joke","rabid donkey","game","quit","help","raging","hurt","fire","","thanos","erics mad","danger","sad","upset","","","creator","thanks","lol","ok","k","yep","report","owner","maker","jarvis","coder","thank you","sup","whats up","what's up","hey","hah") 

resp2 = input("") 

esa = "" 
for word in lis: 
    if word in resp2: 
     esa = word 

    if esa in ("quit","bye","gtg","got to go","see you","c u"): 
      byebro = random.choice(("ok bye Sergei cu later","bye sir","c u later sir","talk to you later then","talk to you later")) 
      print (byebro) 
      os.system("say '"+byebro+"'") 
      exit() 

    if esa in ("look up","web search","search the web for"): 

      c = random.choice(("ok","lets see","let me see","ok sir il get right on that lets see","im looking up and i dont see anything??")) 
      print (c) 
      c1 = ("sorry an error has acurred package missing") 
      print (c1) 

      os.system("say '"+c+"'") 
      os.system("say '"+c1+"'") 
      break 


    if esa == "add note": 
      d = random.choice(("ok sir one sec il pull up the note pad","ok sir one sec","yeah one sec il pull it up","one sec sir","ok","ok sir")) 
      print (d) 
      os.system("say '"+d+"'") 
      note1 = input("") 
      notes.append(note1) 
      break 

    if esa == "get note": 
      e = random.choice(("ok sir one sec il pull up the your recent notes","ok sir one sec","yeah one sec il pull it up","one sec sir","ok","ok sir notes","ok sir")) 
      print (e) 
      os.system("say '"+e+"'") 

[OK]をif文これらの何百もあるので、しかし、私は話をすることができるようにしたいですこのようなジャービスに。私は何かを言うことができ、それから彼はそれについて私に尋ねるでしょう、そして、私は答えます、そして、それはif文から壊れて、ループとすべてのif文をまた通過します。

は私:私は

ジャーヴィスをジャービス接地しています:あなたが何をしましたか?

は私:私は

ジャービス窓を壊した:ああOK

はので、私は、コードは次のようになりたいが、それは私はあなたが必要とするそれを考え出し

if esa in ("im grounded","im in trouble","i got detention"): 
    print "your always getting in trouble its like second nature to you" 
    esa3 = input("what did you do") 
if esa3 in ("i broke something","i smashed something"): 
    print "your always breaking stuff" 
+0

whileループでforループまたはanother whileループを使用する必要がありますか? – techset

答えて

0

を動作しません。 if文をif文の中に入れるには

if esa in ("im grounded","im in trouble","i have detention","i got detention"): 
      punish = random.choice(("your always getting in trouble its like second nature for you lol","to bad i guess no fun for a while well its your fault lol","did you and eric do somthing stupid?!")) 
      print(punish) 
      os.system("say '"+punish+"'") 
      wdydQ = random.choice(("what did you do!!?!!","what did you do this time","can you go one week with out geting exspelled or suspended or in trouble what did you do!!")) 
      print (wdydQ) 
      os.system("say '"+wdydQ+"'") 

      lisgrd = ("i broke","i smashed","i destroyed","i cracked","i hit","i didn't","i hurt","i jumped","i had sex","i went to") 

      respgrd = input("") 

      esagrd = "" 
      for wordgrd in lisgrd: 

      if wordgrd in respgrd: 

       esagrd = wordgrd 




      if esagrd in ("i broke","i smashed","i destroyed","i cracked"): 

      YbsA = random.choice(("your always breaking shit","im not paying for it this time and niether am i taking the blame!")) 
      print (YbsA) 
      os.system("say '"+YbsA+"'") 
      break 
      elif esagrd in ("i hit","i didn't","i hurt","i jumped","i had sex","i went to"): 
      grd33 = random.choice(("i dont know what to say now","oh my god","your fing mental","are you kidding me")) 
      print (grd33) 
      os.system("say '"+grd33+"'") 
      break 
      elif esagrd in ("nothing","i dont know","i don't know","um"): 
      grdq12 = random.choice(("don't bs me whatcha do!!","just tell me what happened","whatever")) 
      print (grdq12) 
      os.system("say '"+grdq12+"'") 
      continue 
+0

ifがforループで整列されていることを確認しますif if wordgrd – techset

関連する問題