Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bot = {}
- local moves = {0,1,2,'-','='}
- local nameStarts = {"Curious","Ultra","Mega","Cool","New","Smart","Dr","Mr"}
- local nameBodies = {"Robit","Robot","Bot","Thinker","Brain","George","Geobots","Taco"}
- local nameEnds = {"9000","MkI","MkII","MkIII"," but FASTER"}
- function bot.new()
- local t = {}
- t.mind = {["0:0"]=0}
- t.tempMind = {["0:0"]=0}
- t.lifetimeScore = 0
- t.name = ""
- for i=1, math.random(0,2) do
- t.name = t.name .. nameStarts[math.random(#nameStarts)]
- end
- for i=1, math.random(1,2) do
- t.name = t.name .. nameBodies[math.random(#nameBodies)]
- end
- for i=1, math.random(0,1) do
- t.name = t.name .. nameEnds[math.random(#nameEnds)]
- end
- function t.try(ammoMe,ammoThem)
- local m = t.tempMind[ammoMe..":"..ammoThem] or moves[math.random(#moves)]
- while (ammoMe < 1 and m == 1) or (ammoMe < 2 and m == 2) or (ammoThem < 1 and m == '-') or (ammoThem < 2 and m == "=") do
- m = moves[math.random(#moves)]
- end
- t.tempMind[ammoMe..":"..ammoThem] = m
- return m
- end
- function t.reward()
- t.mind = t.tempMind
- end
- function t.punish()
- t.tempMind = t.mind
- if math.random(10)>9 then
- local keys = {}
- for k, v in pairs(t.tempMind) do
- keys[#keys+1] = k
- end
- if #keys == 1 then
- t.tempMind[keys[1]] = nil
- elseif #keys > 1 then
- t.tempMind[keys[math.random(#keys)]] = nil
- end
- t.tempMind['0:0'] = 0
- elseif math.random(100)>99 then
- t.tempMind = {['0:0']=0}
- end
- -- Do nothing, one of our changes was BAAD.
- end
- function t.tostring()
- local s = t.name..": "..t.lifetimeScore.."\n"
- for k,v in pairs(t.mind) do
- s = s .. k .. '\t' .. v .. '\n'
- end
- return s
- end
- return t
- end
Add Comment
Please, Sign In to add comment