Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Last active December 17, 2015 21:29
Show Gist options
  • Select an option

  • Save practicingruby/5675186 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/5675186 to your computer and use it in GitHub Desktop.
require_relative "../lib/terrarium"
sim     = Terrarium::Simulator.new
display = Terrarium::Visualization.new

sim.notify(display)



grass = sim.patches! { set_patch_color(:green) if rand(1..500) == 1 }

sim.create_creatures(100)

sim.creatures { lt(rand(0..359)) }

wiggle = sim.creatures! { rt(rand(1...40)); lt(rand(1..40)); fd(0.2) }

eat    = sim.creatures! do 
           sim.world.update_patch(xpos.round, ypos.round) do |e| 
             e.set_patch_color :black 
           end 
         end

Animation of eating bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment