Showing posts with label kedama. Show all posts
Showing posts with label kedama. Show all posts

Sunday, October 28, 2007

Kedama: a GUI-tile scriptable massively-parallel particle system

Kedama is the StarLogo approach imported to etoys. ie.
... a programmable modeling environment for exploring the workings of decentralized systems -- systems that are organized without an organizer, coordinated without a coordinator ... you can model (and gain insights into) many real-life phenomena, such as bird flocks, traffic jams, ant colonies, and market economies
I've been arguing on the Victorian teachers list recently that this is the sort of thing that computers ought to be used for in schools, to add something unique and valuable to the curriculum

Kedama comes with etoys (squeak). It was developed by Yoshiki Ohshima, who is a member of Alan Kay's Viewpoints Research Institute team

There is a wonderfully clear tutorial Linda Kao, with detailed explanations, on the squeakland site.

Visualise kedama as consisting of 3 layers:
  • Kedama world layer
  • Patches layer 100x100 grid (each patch might consists of just 2x2 pixels) and each cell can be assigned an integer value
  • Turtle breeds (particles). A breed is a group of turtles. Turtle breeds are scripted as a group. You can also have multiple breeds for more complex simulations
The turtles can alter their behaviour by interacting with the patch variables. For example, if a patch has a value of 1, then any turtle entering that patch could be programmed to change colour

So, for an epidemic simulation:
  • Create hundreds of turtles (one breed)
  • Infect one of the turtles, show this by displaying that turtle in a different colour
  • Use an infected turtle to infect a patch
  • If any other turtle enters an infected patch then it becomes infected
  • Run the simulation, see how fast the infection spreads

I include some screenshots of three scripts and the developing epidemic:











Some things I learnt:

If I pull out the third line of the infect script and then run the setup script then all turtles immediately become infected

Looking behind the scenes I see that Squeak has a doSequentialCommand: keyword method which somehow carries out the commands to the turtles in each breed one by one. Hence the setup script stops at the point of infecting a single turtle

If I pull out the "patch clear" line of the spread script then the infection spreads much more quickly. This is equivalent to infected surfaces continuing to remain infectious. This illustrates the potential of the patch approach, much more versatile than programming collisions.

spread script pseudocode:
  1. move all turtles
  2. clear all patches
  3. If turtle is infected then infect the immediate patch
  4. If another turtle which is NOT infected enters that patch then infect that turtle