The goal of this tutorial is to showcase the usage of Alchemist-SAPERE, by a sequence of working examples and increasingly challenging exercises.
Introductory material to the simulation world and to the process that led to the creation of Alchemist and of its SAPERE incarnation are provided here.
More information on how to write simulations in Alchemist are provided on the official website.
Alchemist requires a working installation of the Java Development Kit 11 or newer to run. We do recommend either OpenJDK or OpenJ9 from AdoptOpenJDK. Several architectures, operating systems, and JDK versions are tested for compatibility.
When running with docker, installing Java Development Kit is not needed.
Docker and docker-compose are needed in order to run this project in container.
To run on OS X and Windows machines additional X Window System program will be needed.
Eg. xquarts
for OS X and Xming
for Windows.
To run run project use docker-compose up
. Simulation can be specified eg. in docker-compose.yml
file.
The project is managed via the Gradle Build Tool. You do not need to install it, the launch script will download the correct version for you.
In order to launch a simulation named SIMNAME
,
a file named SIMNAME.yml
must be in the src/main/yaml
folder of the project.
That's where the build script will look up.
There will be one Gradle task for each simulation file, which can be executed as:
./gradlew SIMNAME
If an effects file named SIMNAME.json
is present in the effects
folder, it will be loaded automatically.
NOTE the environment variable CI
is used to determined whether the task is running in a headless continuous integration environment.
If you have CI=true
in your environment, the graphical interface won't get pulled up.
Using the provided simulation and the documentation provided on the official Alchemist website, and in particular in reference guide to the YAML simulations and in the SAPERE incarnation reference, and the graphical interface usage description available here, try to solve the following exercises:
- Add two nodes to an empty, continuous environment, and make them connected
- Create 10000 nodes randomly displaced inside a circle centered in (0,0) and radius 10
- Create a grid of nodes from (-5,-5) to (5,5), with nodes every (0.25,0.25) distance units, and no perturbance
- Create a perturbed grid from the example above
- Put some {token} LSAs in some nodes of the system
- Write a "dodgeball" program
- See how YAML can be used to write personalised sections and how they can be referred
- Modify the dodgeball program so that it counts in the LSA the number of passes
- Write an LSA diffusion program: after some time, every node of the network must have the {token} LSA. Use the
*
operator - Look at the
10-math.yml
file. Esperiment with it and try to move nodes around manually. - Write a gradient, it should:
- convert a
{source}
to a{gradient, 0}
(don't delete the source!) - diffuse to neighbors the gradient, whose value is increased of
#D
- if there are multiple copies of the gradient, keep only the lowest (immediately!)
- every some time "age" the information by increasing its value
- delete gradients whose value is higher than some threshold (e.g. 20).
- convert a
- Take a look to
12-sets.yml
, and see how the set arithmetic works. Run it, and see the result. - Modify the program above by changing the time distribution, using a personalised one: a DiracComb with parameter 0.5
- Take a look to
14-yaml.vars.yml
, and make sure to understand how the variables system works - Take a look to
15-move.yml
, run it and play with its variables - Try to run
16-maps.yml
(note: it can take some time on the first load). Get a glance of the possible complexity of advanced scenarios. Discuss the result, modify the example as you like.