Updated AI code and added some more responses.

This commit is contained in:
Izaya 2016-01-14 20:38:17 +11:00
parent 17f1d09e76
commit 35bcb741f2
2 changed files with 15 additions and 3 deletions

5
ai.lua
View File

@ -5,9 +5,12 @@
{"I really like Queens of the Stone Age","Paramore is pretty good.","Green Day is great to listen to."}, {"I really like Queens of the Stone Age","Paramore is pretty good.","Green Day is great to listen to."},
{"music","favorite","like","?"} {"music","favorite","like","?"}
},{ },{
{"!cookie %s","\01ACTION gives %s a snowflake-shaped cookie\01","!cookie yukichan","!cake %s"},
{"cookie","biscuit","want","?"},true
},{
{"tsunbot a shit","tsunbot should pull a ThatAnon","tsunbot should self-terminate."}, {"tsunbot a shit","tsunbot should pull a ThatAnon","tsunbot should self-terminate."},
{"tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot",} {"tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot","tsunbot",}
},{ },{
{"Yes.","No.","Perhaps."}, {"Yes.","No.","Perhaps."},
{"?","?"} {"?","?"},true
}} }}

View File

@ -21,8 +21,9 @@ if string.find(message,lnick) ~= nil and nick ~= "Shocky" then
for k,v in ipairs(aitab) do for k,v in ipairs(aitab) do
local count = 0 local count = 0
for l,w in ipairs(v[2]) do for l,w in ipairs(v[2]) do
if message:find(w) then count = count + 1 print ("yes") end if message:find(w) then count = count + 1 end
end end
if config.debug then print(k.. " = " ..count) end
if count > hscore then if count > hscore then
selection = k selection = k
hscore = count hscore = count
@ -31,11 +32,19 @@ if string.find(message,lnick) ~= nil and nick ~= "Shocky" then
end end
if hscore == 0 then if hscore == 0 then
-- print("No high score, selecting a random response.") -- print("No high score, selecting a random response.")
selection = math.random(1,#aitab) local rtab = {}
for k,v in pairs(aitab) do
if v[3] == true then
table.insert(rtab,k)
end
end
selectrand = math.random(1,#rtab)
selection = rtab[selectrand]
end end
-- print(selection) -- print(selection)
seltab = aitab[selection][1] seltab = aitab[selection][1]
selstring = seltab[math.random(1,#seltab)] selstring = seltab[math.random(1,#seltab)]
selstring = selstring:format(nick)
if type(selstring) == "table" then if type(selstring) == "table" then
for k,v in pairs(selstring) do for k,v in pairs(selstring) do
--print(k.."="..v) --print(k.."="..v)