Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save practicingruby/5685285 to your computer and use it in GitHub Desktop.
Terrarium::Scenario.define do
  # create the forest
  patches do
    with_probability(0.4) { set_color :green }
  end

  # establish fire spreading behavior
  patches! do
    if color == :green && neighbors.any? { |e| e.color == :red }
      set_color :red
    end
  end

  # start the fire!
  random_patch { set_color :red }
end

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