☄️
SpaceTode
  • Introduction
  • Element
  • Properties
  • Data
  • Arguments
  • Rules
  • Diagrams
  • Inputs
  • Outputs
  • Transformations
  • Symmetries
  • Symbols
  • Event Arguments
  • Maybe
  • Point of View
  • Actions
  • Mimic
  • Sub-Elements
  • Blocks
  • Scoping
  • JavaScript
  • Behave
  • Tabs and Spaces
Powered by GitBook
On this page
  • Given
  • Change
  • Keep
  • Select
  • Check
  • Origin

Was this helpful?

Symbols

PreviousSymmetriesNextEvent Arguments

Last updated 4 years ago

Was this helpful?

In the SandPond engine, there are already some in-built and 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 .

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()

@ => @
_    W

This 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

@ => n

This does nothing...

Keeps can still have a function like usual, so they are useful for side-effects.

keep n () => print("I'm doing nothing!")

@ => n

Select

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 => _
_    @
input
output
event arguments list