«prev1 2 3 4

Packing your simulation

For Siafu to run your simulation, you still need to conform to a directory structure and write a config file. You're almost there!

The directory structure

In short, this is how your files have to end up. There are three directories, one for your classess, one for the configuration, and one for all the images, and we'll go through them in the next sections. For reference, here are the full contents of testland.jar:

/etc/config.xml: simulation configuration

A file describing what is what in the simulation. Take this config.xml. Do check the overlay types, where you can see how binary, discrete and real overlays are mapped to their context values.

Your classes

You need to extend the Agent, World and Context model, and those classes, together with any that you may need, have to be in a folder, which will constitude your package name. Don't forget to point to them in the confifuration file for the simulation.

/res/map: all those images

All the images have to be in PNG format, and have the same dimensions as background.png. Map contains the background and walls images, overlays has the initial values of the context overlays, and places has an image per place type, as explained before.

/res/sprites: sprites?

Yes. Sprites. Those little guys that move around. Or boats. Or cars or anything you want! For starters I suggest you take the sprites taht come in testland.jar. You can always modify them later. Again, you need to point to the right set (you get three sizes in testland.jar) in the config file

The naming of the sprites is important. Each PNG follows the format (SpriteName)-(FeetRow).(FeetCol)-(Direction).png, where:


And you are done! The final result should resemble testland.jar. You may put it in a jar or leave it in an open directory, Siafu will accept both. I recommend you pack it all only when you're done with the simulation, to avoid re-jarring at each fix.

And you're done! Now go ahead and do a cool simulation, and if you can, share it! We'd love to put it on the simulations section! Again, feedback appreciated on the whole of Siafu, and specially on the completeness of this tutorial so you know, you can find me here.


Latest code


Creating your own simulation