<commit_before>class Square < Array
  attr_accessor :x, :y, :map
  def ch
    if self == [] then
      return ' '
    else
      self.reverse.max_by {|t| t.show_priority}.ch
    end
  end

  def x=(x)
    self.each {|t| t.x=x}
    @x=x
  end

  def y=(y)
    self.each {|t| t.y=y}
    @y=y
  end

  def <<(t)
    t.x = self.x
    t.y = self.y
    t.map = self.map
    super
  end

  def collision?
    self.any? {|t| t.collision?}
  end

  def collision!(p)
    self.each {|t| t.collision! p}
  end

  def map=(map)
    self.each {|t| t.map=map}
    @map = map
  end

  def blocks_vision?
    self.any? {|t| t.blocks_vision?}
  end
end

class Thing
  attr_accessor :map, :x, :y
  def ch
    nil
  end

  def collision?
    false
  end

  def blocks_vision?
    false
  end

  def collision!(p)
  end

  def move(dir, amt)
    self.map[self.x, self.y].delete(self)
    self.send dir + "=", (self.send dir) + amt
    self.map << self
  end

  def inspect
    "Thing.new"
  end
end

class Player < Thing
  attr_accessor :inventory
  def initialize(attr, inventory = nil)
    @attr = attr
    @inventory = inventory || []
  end

  def <<(thing)
    @inventory.push(thing)
  end

  def ch
    ?@
  end

  def visible?(p)
    self.map.visible?([self.x, self.y], p)
  end

  def display
    if @old_map.nil? then
      @old_map = Map.new(20, 10)
    end

    #@old_map.each_square do |s|
      #if not self.visible? [s.x, s.y] then
        #Termbox.tb_change_cell s.x, s.y, s.ch.ord, 1, 0
      #else
        #@old_map[s.x, s.y] = Square.new
      #end
    #end

    self.map.each_square do |s|
      #if self.visible? [s.x, s.y] then
        Termbox.tb_change_cell s.x, s.y, s.ch.ord, 4, 0
        #@old_map << s.dup
      #end
    end
  end
<commit_msg>everything works! Now using Square<commit_after>class Square < Array
  attr_accessor :x, :y, :map
  def ch
    if self == [] then
      return ' '
    else
      self.reverse.max_by {|t| t.show_priority}.ch
    end
  end

  def x=(x)
    self.each {|t| t.x=x}
    @x=x
  end

  def y=(y)
    self.each {|t| t.y=y}
    @y=y
  end

  def <<(t)
    t.x = self.x
    t.y = self.y
    t.map = self.map
    super
  end

  def collision?
    self.any? {|t| t.collision?}
  end

  def collision!(p)
    self.each {|t| t.collision! p}
  end

  def map=(map)
    self.each {|t| t.map=map}
    @map = map
  end

  def blocks_vision?
    self.any? {|t| t.blocks_vision?}
  end
end

class Thing
  attr_accessor :map, :x, :y
  def ch
    nil
  end

  def collision?
    false
  end

  def blocks_vision?
    false
  end

  def collision!(p)
  end

  def move(dir, amt)
    self.map[self.x, self.y].delete(self)
    self.send dir + "=", (self.send dir) + amt
    self.map << self
  end

  def inspect
    "Thing.new"
  end
end

class Player < Thing
  attr_accessor :inventory
  def initialize(attr, inventory = nil)
    @attr = attr
    @inventory = inventory || []
  end

  def <<(thing)
    @inventory.push(thing)
  end

  def ch
    ?@
  end

  def visible?(p)
    self.map.visible?([self.x, self.y], p)
  end

  def display
    if @old_map.nil? then
      @old_map = Map.new(20, 10)
    end

    @old_map.each_square do |s|
      if not self.visible? [s.x, s.y] then
        Termbox.tb_change_cell s.x, s.y, s.ch.ord, 1, 0
      else
        @old_map[s.x, s.y] = Square.new
      end
    end

    self.map.each_square do |s|
      if self.visible? [s.x, s.y] then
        Termbox.tb_change_cell s.x, s.y, s.ch.ord, 4, 0
        s.each {|t| @old_map << t.dup}
      end
    end
  end

{'fraction_non_alphanumeric': 0.13920454545454544, 'fraction_numerical': 0.004545454545454545, 'mean_word_length': 1.978849407783418, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 3, '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': '6654379', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1465, 'n_words': 378}