Home

Vince Allen edited this page Dec 12, 2013 · 22 revisions

FloraJS is a library of classes and helpers for creating natural simulations in a web browser. Flora defines a natural simulation as a collection of autonomous agents whose boundaries of autonomy appear to be defined by natural forces. Using Flora's classes and a DOM renderer called Burner, you can create a system of autonomous agents that appear to inhabit a natural environment.

I decided to build FloraJS after reading both Daniel Shiffman's Nature of Code and Valentino Braitenberg's Vehicles: Experiments in Synthetic Psychology. In Braitenberg's book, he imagines 10 hypothetical vehicles equipped with sensors that increase in complexity as the book progresses. Flora uses formulas from Nature of Code and Braitenberg's concepts to visualize natural systems and the emergent behaviors that arise within them.

Getting started

Building a system involves attaching simple rules to vehicles called Agents and placing these vehicles in an environment. In a web browser, you can use the document's body or one or more DOM elements to represent your environment. The Burner DOM renderer takes care of updating the screen and handling events like resizing.

You can exert influence over your vehicles directly from the environment via your world's gravity. You can also add influencers like Attractors and Repellers that exert forces. You can also equip your vehicles with sensors tuned to specific stimuli and invoke behaviors when the sensors activate. Predefined behaviors mirror Braitenberg behaviors like AGGRESSIVE, COWARD, LIKES, etc.

Flora classes can be divided into three types.

  • Agent items - Classes for creating autonomous agents.
  • Agent extras - Classes for decorating autonomous agents.
  • Environmental items - Classes for influencing agents.

Flora also organizes classes in a hierarchy.