Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- return"Match",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 hist()return #t==0 and math.random(3)-1 or(t[math.random(#t)]+1)%3 end
- names[hist]="hist"
- local function hist3()return #t==0 and math.random(3)-1 or(t[math.random(math.max(1,#t-3),#t)]+1)%3 end
- names[hist3]="hist3"
- local f={}for a,_ in pairs(names)do f[#f+1],set[a]=a,0 end
- for i=1,#f do local x=function()t,t2=t2,t local r=f[i]()t,t2=t2,t return r end set[x]=0 names[x]="anti"..names[f[i]]f[#f+1]=x end
- for i=1,#f do local x=function()return(f[i]()+1)%3 end local y=function()return(f[i]()+2)%3 end set[x]=0 set[y]=0 names[x]=names[f[i]].."+1" names[y]=names[f[i]].."+2"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