Advertisement
Guest User

Psycholua-gist.lua

a guest
Jan 22nd, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.67 KB | None | 0 0
  1.  
  2. score={{}}
  3. score["learnstrings"]={}
  4. AI_RESPONSE={"what does that make you think?"
  5. ,  "have you thought much about the end result of that?"
  6. ,  "maybe we should talk about something else."
  7. ,  "you realize I only listen to you since it's my job. But go on."
  8. ,  "if that's entirely true, you would have made more of a point."
  9. ,  "pretending you are your guardian angel, tell me your opinion."
  10. ,  "what if you were to walk off a cliff today?"
  11. ,  "are you aware of your surroundings much?"
  12. ,  "if you were, you'd understand I might not be"
  13. ,  "time for you to get a break for a while."
  14. ,  "how come you always say dumb responses?"
  15. ,  "You come here to share your problems with me."
  16. ,  "Is there something I should know?"
  17. ,  "maybe you should tell me things in more detail."
  18. ,  "Is that really the reason?"
  19. ,  "do you even trust me?"
  20. ,  "It's OK. I understand. It's my job to understand. My job is to help you."
  21. ,  "more secrets, less mumbo-jumbo, OK."
  22. ,  "I don't know why I even try. Wait, I do, It's my job."
  23. ,  "Is there something you'd rather be talking about?"
  24. ,  "I look like this :-) but even us psychologists lie."
  25. ,  "You know what I think?"
  26. ,  "There was a cat that wore a hat and sat on mat and it was fat and that was that."
  27. ,  "You need a vacation."
  28. ,  "There's a pot of gold at the end of every rainbow."
  29. ,  "When is groundhog day?"
  30. ,  "You need to look at the big picture."
  31. ,  "what was accomplished?"
  32. ,  "You should be more assertive"
  33. ,  "You should finish something"
  34. ,  "Don't you even pay attention to your instincts? They're there to help you."
  35. ,  "You don't understand how others see you"
  36. ,  "What's your ultimate goal?"
  37. ,  "You tend to concentrate too much on one thing and forget another thing: Comb hair, ignore teeth. You're nice, but think too fast..."
  38. ,  "Do you try many new things?"
  39. ,  "Want my advice? Take a philosphy class."
  40. ,  "I think your dog understands you better than most people."}
  41.  
  42. math.randomseed(os.time()) ; -- RANDOMIZE TIMER
  43.  
  44.  
  45. function listTableForOutput(TableName)
  46.     local Q = '"';
  47.     local ba="{";
  48.     local bb="}";
  49.     local C=",";
  50.  
  51. local listout = ""
  52. local scoreword={}
  53. local wordlist=""
  54.         for i = 1,#score[TableName],1 do
  55.         scoreword=score[TableName][i]  
  56.        
  57.             qfind = string.find(scoreword,Q)
  58.             if qfind == nil then
  59.             scoreword=Q..scoreword..Q
  60.             end
  61.        
  62.        
  63.         listout = listout..scoreword..C
  64.         end
  65.        
  66.          scoreout="\n".."score["..Q..TableName..Q.."]="..ba..string.sub(listout,1,-2)..bb;
  67.    
  68.     return scoreout
  69. end
  70.  
  71. function WriteTablesToFile()
  72. tableListsFile = "psycholuagist_learn.lua"
  73.     local f = io.open(tableListsFile,"w")
  74.     local Q = '"';
  75.     local ba="{";
  76.     local bb="}";
  77.     local C=",";
  78.  
  79.     if f ~= nil then
  80.     listwrite="\n"
  81.         listwrite = listwrite.."\n"..listTableForOutput("learnstrings")
  82.         f:write(listwrite)
  83.         f:write(string.char (10))
  84.         io.close(f)
  85.     end
  86. end
  87.  
  88.  
  89. helloText=[[ Hello.
  90. Welcome to psycholua-gist
  91. Derived from  psychic-ologist (for basic) by Nathan Wittich
  92.  
  93. This 'Artificial inteligence' will talk to you.
  94.  Note: if something doesn't directly make sense, It may
  95. be sort of symbolic or something.
  96.  
  97. Also, you have to act human for me to act human.
  98. For example, if a human says something twice,
  99. you say 'you already said that' not 'you're stupid'.
  100.  
  101. Also note: you don't have to answer.]]
  102.  
  103. print(helloText)
  104.  
  105.  
  106.  
  107. function runEliza()
  108.     local input
  109.     local ps1 = ps1 or "> "
  110.     while true do
  111.         io.stdout:write(ps1)
  112.         input = io.stdin:read(); --LINE INPUT "", a$
  113.         if not input then io.stdout:write('\n') return end
  114.          g = "  "..AI_RESPONSE[math.random(1,#AI_RESPONSE)] ; -- g$ = n$(1 + INT(RND * a))     
  115.         print(g)
  116.         table.insert(score["learnstrings"],input)
  117.         WriteTablesToFile()
  118.     end
  119.    
  120. end
  121. runEliza()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement