<commit_before>local ai = {}

function ai.update( entities, map )
  for i, entity in ipairs( entities ) do
    if entity.owner ~= 0 then -- not owner
      target = nil
      for ii, ee in ipairs( entities ) do
        if ee.owner == 0 and math.abs( ee.x - entity.x ) + math.abs( ee.y - entity.y ) < 10 then
          -- seek and destroy!
          target = ee
        end
      end

      if target ~= nil and entity.health / entity.maxhealth > 0.4 then
        entity.target = target
        entity.targetcommand = 'attack'
      else -- run!!!
        if table.maxn( entity.pathtable ) == 0 then
          entity.ty, entity.tx = math.random( map.width ), math.random( map.height )
        end
      end
    end
  end
end

return ai<commit_msg>make AI more sluggish (#5)<commit_after>local ai = {}

function ai.update( entities, map )
  for i, entity in ipairs( entities ) do
    -- dumb "wait" action
    if math.random( 10 ) > 6 then
      -- don't do anything
    else
      -- smart logic
      if entity.owner ~= 0 then -- not owner
        target = nil
        for ii, ee in ipairs( entities ) do
          if ee.owner == 0 and math.abs( ee.x - entity.x ) + math.abs( ee.y - entity.y ) < 10 then
            -- seek and destroy!
            target = ee
          end
        end

        if target ~= nil and entity.health / entity.maxhealth > 0.4 then
          entity.target = target
          entity.targetcommand = 'attack'
        else -- run!!!
          if table.maxn( entity.pathtable ) == 0 then
            entity.ty, entity.tx = math.random( map.width ), math.random( map.height )
          end
        end
      end
    end
  end
end

return ai
{'fraction_non_alphanumeric': 0.10576923076923077, 'fraction_numerical': 0.010817307692307692, 'mean_word_length': 1.659744408945687, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4455489', 'n_tokens_mistral': 528, 'n_tokens_neox': 509, 'n_words': 176}