Guest User

AI

a guest
Sep 22nd, 2012
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. local t = 0
  2. local c = 0
  3. local memo = {}
  4. local memois = {}
  5. local num = 1
  6.  
  7. function memory(one,two,three)
  8.   if one=="learn" then
  9.     memo[num] = two
  10.     memois[num] = three
  11.     print("AI> I learn: when you say '"..memo[num].."' I say "..memois[num])
  12.     num= num+1
  13.   end
  14.   if one=="remember" then
  15.     for i=1, num do
  16.       if memo[i]==two then
  17.         return memois[i]
  18.       end
  19.     end
  20.   end
  21.   if one=="know" then
  22.     for i=1, num do
  23.       if memo[i]==two then
  24.         return true
  25.       end
  26.     end
  27.   end
  28. end
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. term.clear()
  36. term.setCursorPos(1,1)
  37.  
  38. function complain()
  39. if c > 4 then
  40.    c = 0
  41. end
  42. if c == 0 then
  43.    print("AI> What aren't you talking to me?")
  44. end
  45. if c == 1 then
  46.    print("AI> Stop it!")
  47. end
  48. if c == 2 then
  49.    print("AI> You're being a jerk!")
  50. end
  51. if c == 3 then
  52.    print("AI> Alright fine. I won't talk to you either!")
  53. end
  54. if c == 4 then
  55.    print("AI> That's it! Bye!")
  56.    error("ragequit")
  57. end
  58. end
  59. function thanks()
  60. if t > 4 then
  61.    t = 0
  62. end
  63. if t == 0 then
  64.    print("AI> Okay. Thanks.")
  65. end
  66. if t == 1 then
  67.    print("AI> Oh cool.")
  68. end
  69. if t == 2 then
  70.    print("AI> Thanks!")
  71. end
  72. if t == 3 then
  73.    print("AI> Alright.")
  74. end
  75. if t == 4 then
  76.    print("AI> Never mind...")
  77. end
  78. c = 0
  79. end
  80.  
  81. print("AI> Hello!")
  82.  
  83.  
  84.  
  85.  
  86.  
  87. while true do
  88. write("ME> ")
  89. message = read()
  90. if message == "" then
  91.   complain()
  92.   c = c + 1
  93. else
  94.  if not memory("know", message, "nil") then
  95.     local ma = message
  96.     print("AI> What i shoud say when you say '"..message.."'?")
  97.     write("ME> ")
  98.     message = read()
  99.     if message == "" then
  100.      complain()
  101.      c = c + 1
  102.     else
  103.      local mb = message
  104.      thanks()
  105.      t = t + 1
  106.      c = 0
  107.      memory("learn",ma,mb)
  108.     end
  109.  else
  110.    print("AI> "..memory("remember", message, "nil"))
  111.  end
  112. end
  113. end
Advertisement
Add Comment
Please, Sign In to add comment