Implementing ideas from this book http://natureofcode.com/ in JavaScript