<commit_before>require 'graphics.rb'
require_relative '../helpers/rainbows'

class Ball < Graphics::Body

  attr_accessor :polyp, :c, :r, :store, :leaf

  COUNT = 1_000
  PURPLISH = "cubehelix_280".to_sym

  def initialize w
    super
    self.m = self.r = 2 + rand(9)
    self.a = rand 360.0
    self.c = "cubehelix_#{160 + rand(200)}".to_sym
    self.polyp = w.polyp
    self.store = self
    self.leaf = false
  end

  def update
    return if calcified?

    if self.store = polyp.touching(self)
      polyp.attach self
      self.leaf = true
      self.store.leaf = false
    else
      self.store = nil
      move
      wrap
    end
  end

  def calcify
    self.m = 0
  end

  def calcified?
    m == 0
  end

  def touches other
    distance_to_squared(other) <= (r + other.r) ** 2
  end

  class View
    def self.draw w, o
      if o.calcified?
        w.line o.x, o.y, o.store.x, o.store.y, PURPLISH

        if o.leaf
          w.circle o.x, o.y, o.r, o.c, :true
          w.circle o.x, o.y, o.r, :gray
        end

      else
        w.circle o.x, o.y, o.r, o.c, :fill
      end
    end
  end
end<commit_msg>growing tree<commit_after>require 'graphics.rb'
require_relative '../helpers/rainbows'

class Ball < Graphics::Body

  attr_accessor :polyp, :c, :r, :store, :leaf

  COUNT = 1_000
  PURPLISH = "cubehelix_280".to_sym

  def initialize w
    super
    self.m = self.r = 2 + rand(9)
    self.a = rand 360.0
    self.c = "cubehelix_#{160 + rand(200)}".to_sym
    self.polyp = w.polyp
    self.store = self
    self.leaf = false
  end

  def update
    return if calcified?

    if self.store = polyp.touching(self)
      polyp.attach self
      self.leaf = true
      self.store.leaf = false
    else
      self.store = nil
      move
      wrap
    end
  end

  def calcify
    self.m = 0
  end

  def calcified?
    m == 0
  end

  def touches other
    distance_to_squared(other) <= (r + other.r) ** 2
  end

  class View
    def self.draw w, o
      if o.calcified?
        w.line o.x, o.y, o.store.x, o.store.y, PURPLISH

        if o.leaf
          w.circle o.x, o.y, o.r, o.c, :true
          w.circle o.x, o.y, o.r, :gray
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11436413540713632, 'fraction_numerical': 0.020128087831655993, 'mean_word_length': 1.8439531859557867, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4604425', 'n_tokens_mistral': 896, 'n_tokens_neox': 835, 'n_words': 225}