Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- return"Amalgam",function(t,t2)
- local set,names={},{}
- local function cycle()return #t%3 end
- names[cycle]="cycle"
- local change do
- local last=math.random(3)-1
- change=function()
- last=(last+math.random(2))%3
- return last
- end
- end
- names[change]="change"
- local function beatlast()
- return #t==0 and math.random(3)-1 or(t[#t]+1)%3
- end
- names[beatlast]="beatlast"
- local winstay do
- local last=math.random(3)-1
- winstay=function()
- if #t~=0 and last~=(t[#t]+1)%3 then
- last=(last+math.random(2))%3
- end
- return last
- end
- end
- names[winstay]="winstay"
- local function difflast(t)
- return function()
- return((t[#t]or math.random(3))+math.random(2))%3
- end
- end
- names[difflast]="difflast"
- local function hist(t)
- return function()
- return #t==0 and math.random(3)-1 or(t[math.random(#t)]+1)%3
- end
- end
- names[hist]="hist"
- local f={}for a,_ in pairs(names)do f[#f+1],set[a]=a,0 end
- local function rand()return math.random(3)-1 end set[rand]=0 names[rand]="rand"
- local last={}
- return function()
- local r=t[#t]
- local name="rand"
- if r then
- local mv,m=-math.huge,rand
- for f,v in pairs(set)do
- local a,b=last[f],r
- if a==(b+1)%3 then
- v=v+1 set[f]=v
- elseif a~=b then
- v=v-1 set[f]=v
- end
- if v>mv then m,mv=f,v end
- end
- ret=m()name=names[m]
- else
- ret=rand()
- end
- for f,v in pairs(set)do last[f]=f()end
- return ret
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement