Date: | Wed, 2 Dec 2015 16:50:14 -0800 |
From: | Toby Schachman |
Subject: | Re: Simulation in Apparatus |
[I am sending this again because the big attachment might've failed.]Today I played with doing simulations in Apparatus. I specifically want to make Apparatus more "playable". What I mean is: many of the good explorable explanations start out with a "you try to do this" lead-in.You try to make all the polygons happy...You try to make precipitation decrease...You try to color the map with 3 colors...etc.These work well because you get to "play algorithm" (as in Papert's "playing turtle"), so when the algorithm is explained all the motivations fit into place.I wanted to see if "playable simulations" would be possible in Apparatus using a "followed by" feature inspired by Lucid streams.The idea is you write an expression for what a variable should become on the next frame. That expression is allowed to reference the variable's current value (and any other variables of course).I made a few clips of playing with this. Sorry for the sloppy graphic design and implementation. I just wanted to quickly see if the idea would work.The first clip is a simulation where you're heating up a thing and there's a bar on the right that shows the current temperature. This is the lead-in for an explorable explanation I'd like to do about PID control systems ("You try to get it to the target temperature").The second clip is a ball that follows another ball (first demo from Dead Fish).The third clip is the heating simulation where we manually keep a history of the thing's temperature and plot it. The implementation for this is with an array that we update on every frame. But, that is just a stand in because I think Apparatus should have a feature where you can just grab the history of any variable. Right now you can grab the current value of a variable for use in an expression. But you should also be able to grab the history (as a spread) of a variable. "Give me the last 100 values of this variable", "Give me the last 15 seconds of this variable", etc. This feature would also let you easily do "traces", or even make a drawing program (give me the entire history of the x and y positions of the pen object and use it to draw a path).The "followed by" thing is similar to the update step in a game loop. I think the main difference is that it privileges data flow over control flow. In a traditional game loop, you have a block of code that updates lots of variables on every tick. With "followed by", each update rule lives with its variable (lives with the data). I'm not sure whether this will make programming the behaviors better or not. Maybe there will be both a data-centric mechanism ("this variable evolves according to this expression") and a control-centric mechanism ("when you click this rectangle set this other variable to 0"). We'll see.Right now you can turn on and off the followed by rules individually with a checkbox. There will need to be a better designed interface for this, perhaps with a universal pause button and scrubber to go back in time.For those following on Github, there is an experiment-evolve branch. It is hacky, inefficient, and breaks things like reusing symbols. But it works for testing the idea. The examples from the clips are attached.