Guest User

Untitled

a guest
Dec 28th, 2016
173
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bot = {}
  2.  
  3. local moves = {0,1,2,'-','='}
  4.  
  5. local nameStarts = {"Curious","Ultra","Mega","Cool","New","Smart","Dr","Mr"}
  6. local nameBodies = {"Robit","Robot","Bot","Thinker","Brain","George","Geobots","Taco"}
  7. local nameEnds = {"9000","MkI","MkII","MkIII"," but FASTER"}
  8.  
  9. function bot.new()
  10.     local t = {}
  11.  
  12.     t.mind = {["0:0"]=0}
  13.     t.tempMind = {["0:0"]=0}
  14.  
  15.     t.lifetimeScore = 0
  16.  
  17.     t.name = ""
  18.     for i=1, math.random(0,2) do
  19.         t.name = t.name .. nameStarts[math.random(#nameStarts)]
  20.     end
  21.     for i=1, math.random(1,2) do
  22.         t.name = t.name .. nameBodies[math.random(#nameBodies)]
  23.     end
  24.     for i=1, math.random(0,1) do
  25.         t.name = t.name .. nameEnds[math.random(#nameEnds)]
  26.     end
  27.  
  28.     function t.try(ammoMe,ammoThem)
  29.         local m = t.tempMind[ammoMe..":"..ammoThem] or moves[math.random(#moves)]
  30.         while (ammoMe < 1 and m == 1) or (ammoMe < 2 and m == 2) or (ammoThem < 1 and m == '-') or (ammoThem < 2 and m == "=") do
  31.             m = moves[math.random(#moves)]
  32.         end
  33.         t.tempMind[ammoMe..":"..ammoThem] = m
  34.         return m
  35.     end
  36.  
  37.     function t.reward()
  38.         t.mind = t.tempMind
  39.     end
  40.  
  41.     function t.punish()
  42.         t.tempMind = t.mind
  43.         if math.random(10)>9 then
  44.             local keys = {}
  45.             for k, v in pairs(t.tempMind) do
  46.                 keys[#keys+1] = k
  47.             end
  48.             if #keys == 1 then
  49.                 t.tempMind[keys[1]] = nil
  50.             elseif #keys > 1 then
  51.                 t.tempMind[keys[math.random(#keys)]] = nil
  52.             end
  53.             t.tempMind['0:0'] = 0
  54.         elseif math.random(100)>99 then
  55.             t.tempMind = {['0:0']=0}
  56.         end
  57.         -- Do nothing, one of our changes was BAAD.
  58.     end
  59.    
  60.     function t.tostring()
  61.         local s = t.name..": "..t.lifetimeScore.."\n"
  62.         for k,v in pairs(t.mind) do
  63.             s = s .. k .. '\t' .. v .. '\n'
  64.         end
  65.         return s
  66.     end
  67.  
  68.     return t
  69. end
RAW Paste Data