Nature, In Code

Welcome to the website of the book "Nature, in Code". Here you can find all code examples used in the book. In addition, the content of the book is currently turned into a video-based course - you can find the videos on this website.

News & Updates

September 2, 2016
MOOC set to launch on November 7
The MOOC "Nature, in Code" is set to launch on November 7, 2016, on the EdX platform. You can register here: The course will be self-paced, which means you will be able to attend it whenever you find the time, at whichever pace suits you best. See you there!
March 1, 2016
I've started recording videos for an EdX MOOC based on the book. Very exciting! Stay tuned.
August 21, 2015
JavaScript Implementation of ants finding food
I just love looking at these algorithmic little beasts pretending to be alive ;-) Needless to say, simulation is written in JavaScript.
April 12, 2015
JavaScript Implementation of Abelian Sandpile Model
Inspired by an interesting article about the sandpile model, I implemented it in JavaScript.
March 12, 2015
JavaScript Implementation of Schelling's Segregation Model
Schelling's segregation model is perhaps the best-known model in the social sciences that explains a macropattern (segregation) with a microbehavior (slight preference for similar neighbors). The JavaScript implementation is here.
March 6, 2015
JavaScript Implementation of Social Conformity Vs. Individual Distinctiveness
After reading an interesting paper on Social Conformity, I decided to the implement the basic model in JavaScript.
March 1, 2015
Book update - Chapter 8 finished!
I'm very happy to announce that chapter 8 (on the evolution of cooperation) is now finished. I have uploaded the latest version of the book with the full chapter. If you have already bought the book, you can get this update for free, as always. Lean publishing FTW!


If something is missing or wrong, please let me know! Twitter is best: @natureincode. Alternatively, you can send me email at

Marcel Salathé