Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save practicingruby/5621460 to your computer and use it in GitHub Desktop.
require_relative "microworlds"
sim = Microworlds::Simulator.new
display = Microworlds::Visualization.new
sim.notify(display)
sim.up { set_patch_color [:black, :black, :white].sample }
sim.up! do
case neighbors.count { |e| e.color == :white }
when 0..1, 4..8
set_patch_color :black
when 3
set_patch_color :white
end
end
## SEE VISUALIZATION IN GIF BELOW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment