Waffle3z

ResponseCount

Jun 26th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. return"ResponseCount",function(t,t2)
  2. local set={}
  3. for i=0,2 do for j=0,2 do for k=0,2 do set[''..i..j..k]=0 end end end
  4. local function f(i)
  5. local n=''..t2[i-1]..t[i-1]..t[i]
  6. set[n]=set[n]+1
  7. end
  8. for i=2,#t do f(i)end
  9. return function()
  10. local r,p,s=0,0,0
  11. if #t==0 then
  12. return math.random(3)-1
  13. elseif #t~=1 then
  14. f(#t)
  15. local m=''..t2[#t2]..t[#t]
  16. r,p,s=set[m..'0'],set[m..'1'],set[m..'2']
  17. end
  18. if r>p and r>s then return 1
  19. elseif p>s and p>r then return 2
  20. elseif s>p and s>r then return 0
  21. elseif p>s and p==r then return math.random(2)-1
  22. elseif s>r and s==p then return math.random(2)
  23. elseif r>p and r==s then return(math.random(2)+1)%3
  24. else return math.random(3)-1
  25. end
  26. end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment