A program has access to a history of rock-paper-scissors moves and responses and determines a decision for its next move based on its analysis of the previous ones.

submit bots here https://www.roblox.com/games/437771957/RPS-Botwar to battle and rank them
take this https://www.roblox.com/item.aspx?id=442913043 to write and test bots in studio.
(edit: pastebin source instead of roblox model: http://pastebin.com/5gDQrPDr)

some example bots:

``````function Rock() -- returns rock every round
return function()
return 0
end
end

function Random() -- returns a random move every round
return function()
return math.random(3)-1
end
end

function Copy(t) -- returns the opponent's previous move
return function()
return t[#t]or math.random(3)-1
end
end

function BeatLast(t) -- beats the opponent's previous move
return function()
return((t[#t]or math.random(3))+1)%3
end
end

function WinStay(t) -- returns the same move if it won last round, otherwise changes
local last=math.random(3)-1
return function()
if #t~=0 and last~=(t[#t]+1)%3 then
last=(last+math.random(2))%3
end
return last
end
end

function History(t) -- plays against a random move the opponent has made in the past
return function()
return #t==0 and math.random(3)-1 or(t[math.random(#t)]+1)%3
end
end

function Count(t) -- plays against the opponent's most common move
local r,p,s=0,0,0
return function()
local m=t[#t]
if m==0 then r=r+1 elseif m==1 then p=p+1 elseif m==2 then s=s+1 end
if r>p and r>s then
return 1
elseif p>s then
return 2
else
return 0
end
end
end

function Repetition(t,t2) -- predicts the opponent's next move from repeated strings of responses
return function()
local r,len=math.random(3)-1,0
for i=#t-1,1,-1 do
for j=0,i do
if t[i-j]==t[#t-j]and t2[i-j]==t2[#t2-j]then
if j>=len then
r,len=(t[i+1]+1)%3,j+1
end
else
break
end
end
end
return r
end
end
``````