<commit_before># encoding: utf-8

require 'mining_depot/entity'
require 'mining_depot/entities/location'
require 'mining_depot/interactors/truck_loop'

class Truck < MiningDepot::Entity
  attribute :capacity,    Integer, default: 10
  attribute :location,    Location
  attribute :destination, Location, writer: :private
  attribute :load,        Hash[Symbol => Integer], writer: :private
  attribute :behaviour,   Object, default: ::TruckLoop

  def initialize(*args)
    super(*args)
    @semaphore = Mutex.new
  end

  def start
    Thread.new(self) do |truck|
      l = truck.logger
      l.info 'Starting Truck.'

      loop { truck.behaviour.run(truck: truck) }
    end
  end

  def move_to(location)
    semaphore.synchronize { @location = location }
  end

  def location
    semaphore.synchronize { @location }
  end

  def next_destination
  end

  def navigation
  end

  protected

  attr_accessor :semaphore
end<commit_msg>Regression: reinstate terrible next_location method<commit_after># encoding: utf-8

require 'mining_depot/entity'
require 'mining_depot/entities/location'
require 'mining_depot/interactors/truck_loop'

class Truck < MiningDepot::Entity
  attribute :capacity,    Integer, default: 10
  attribute :location,    Location
  attribute :destination, Location, writer: :private
  attribute :load,        Hash[Symbol => Integer], writer: :private
  attribute :behaviour,   Object, default: ::TruckLoop

  def initialize(*args)
    super(*args)
    @semaphore = Mutex.new
  end

  def start
    Thread.new(self) do |truck|
      l = truck.logger
      l.info 'Starting Truck.'

      loop { truck.behaviour.run(truck: truck) }
    end
  end

  def move_to(location)
    semaphore.synchronize { @location = location }
  end

  def location
    semaphore.synchronize { @location }
  end

  def next_destination
  end

  def next_location(current)
    c      = current.coordinates
    x, y   = c[:x], c[:y]
    change = [1, -1].sample

    if rand(4).even?
      current.world[x + change, y]
    else
      current.world[x, y + change]
    end
  end

  def navigation
  end

  protected

  attr_accessor :semaphore
end
{'fraction_non_alphanumeric': 0.09523809523809523, 'fraction_numerical': 0.004201680672268907, 'mean_word_length': 3.243564356435644, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2117773', 'n_tokens_mistral': 724, 'n_tokens_neox': 683, 'n_words': 181}