~dhf/starlogo

Turtles, Termites, and Traffic Jams
interesting behavior for commit 6ac47667079276e4534e3fa560395b37456c7ccc
minor formatting edit: blank lines between procedures
modifications to the world in 'next' state, not current state

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~dhf/starlogo
read/write
git@git.sr.ht:~dhf/starlogo

You can also use your local clone with git send-email.

#Turtles, Termites, and Traffic Jams

#Mitchel Resnick, 1994, MIT Press

#Introduction

StarLogo is a parallel-processing simulation language designed by Mitchel Resnick in the '80s extending ideas from Logo.

Logo was designed to teach children logical and procedural thinking, particularly in terms of "turtle graphics": moving a turtle about on a flat surface and drawing lines. Sophisticated geometry can be explored procedurally: Abelson and DiSessa's Turtle Geometry treats vector graphics, topology, and general relativity.

Resnick designed StarLogo to help teach systems thinking, and used it successfully with groups of high-school students. He describes several of these projects and investigations in Turtles, Termites, and Traffic Jams.

StarLogo specifies simulations in terms of turtles - mobile agents - and patches - fixed pieces of ground. Turtles and patches can have properties which can be set and tested, and procedures that once activated execute repeatedly and concurrently, SIMD fashion, for each patch or turtle.

(The language was first implemented on a Connection Machine, a massively parallel computer; by convention, parallelized versions of various programming languages were marked with a "*", like *Lisp and C*, hence the name StarLogo. Versions of the language were implemented on Macintoshes and in Java.)

I thought it would be fun to implement a StarLogo and play with the simulations described in the book.

#The project

Each simulation from the book is in a directory. So far I've done two, a basic example and slime-mold aggregation. The code is split between library and framework in starlogo.js and the model some other suitably named file.

Each directory has its own starlogo.js file as I figure things out. When finished, it will be a single module.

The models are of course written in StarLogo in the book. When the runtime is stable I'll do a parser. For now, they have to be transcribed into JavaScript.

Proper documentation to follow, but in brief: provide a 'sketch' object with at least a setup and either a step or some demons (otherwise your model won't do much.) The sketch below makes a 1000 turtles that start with random headings and take 1 step forward on each 'tick'.

const sketch = {
  setup: () => {
    clear_all()
    create_turtle(1000)
    sketch.turtle_setup()
    sketch.patch_setup()
  },
  turtle_setup: () => {
    activate_turtle_demon(sketch.walk_demon)
  },
  walk_demon: (t) => {
    t.forward(1)
  },
}

#The models

#A simple example (p.39)
#Slime molds (p.50)