Symbols
In the SandPond engine, there are already some in-built input and output symbols. You can also make your own symbols with these keywords. Define what they do by writing a JavaScript function. Name the arguments you want to use from the event arguments list.
Given
All given inputs must be true for a rule to be chosen.
given W (element) => element == Water
W => _
@ @If there is a water atom above me, delete it.
Change
change outputs say what atom to put in a space.
change W () => new Water()
@ => @
_ WThis makes a water atom and places it below.
Keep
keep outputs don't do anything. They just leave that space how it is.
keep n
@ => nThis does nothing...
Keeps can still have a function like usual, so they are useful for side-effects.
keep n () => print("I'm doing nothing!")
@ => nSelect
select inputs save data that can be used in an output.
given W (element) => element == Water
select W (atom) => atom
change W (selected) => selected
@ => W
W @This selects a water atom below, and swaps places with it.
Check
All check inputs must be true for a rule to be chosen. Only one check function is done per symbol. Unlike given, it is never cached during an event.
given W (element) => element === Water
check W () => Math.random() < 0.2
WWW ...
@ => _Origin
origin symbols show where the centre of the diagram is.
origin O
O => _
_ @Last updated
Was this helpful?