What this is about

Screenshot MicroWorld is a rule driven cellular automaton. What does that mean? Well, it's a two dimensional world made up of squares called cells. The world develops in steps, and at each step, each cell is modified by applying the rules.

Go and watch it running for a few moments, then come back here.

The demonstration world is a mountain, with snow at the top and the sea at the bottom. as you watched, you probably saw the bright green of grass on the lower slopes of the mountain turn to the darker green of forest. You may have seen some forest fires break out.

That's all controlled by rules. You make the rules. To start Noah's flood, go to the rules page now, and add this rule at the very top:

if altitude is less than 200 then state should be water

then, go and watch the world again. What happens? You should see water spread across everywhere except the very top of the mountain. But after the flood, the waters should drain away again. Go back to rules and add this rule at the very top:

if altitude is more than 9 and state is water then state should be grassland

Now the world alternates between new and grassland. That's no good! Go back to rules and delete the rule that you first added - the one that says

if altitude is less than 200 then state should be water

And see! The world starts growing again.

What you can do next

Change some rules

Change some of the other rules and see what happens. Very likely, one of the first things that will happen is that you will get a message like this:

I did not understand 'if state is grassland then 1 chance in 10 state will be heath'

That means that you changed a rule in a way that the engine could no longer understand it. To find out what the engine will understand, have a look at the documentation.

Invent some rules of your own!

What happens when people come into the world? Where would they make their first camp? Would they want to be near the water, so they could fish? Would they want be near fertile grassland, to graze their sheep and cattle?

Write a rule which adds some camps to the world

What happens to the land around a camp? Do the people burn down forest to make new grassland? Do they convert the grassland into meadow, or into crop?

Does growing crops reduce the soil fertility? What makes people decide that their camp is a good enough place to build a proper house?

Write some rules which describe this

How many squares of meadow or crop does it take to feed each house full of people? What happens when there are too many houses and not enough fields? Can houses catch fire? What happens to a house which is next to a fire?

How many houses do you need for a market place? Where would people build a harbour?

Change the rules completely

I've provided rules which use the MicroWorld cellular automaton to make a simple model of the changes to land in Europe after the ice age. But you don't have to use it like that, at all.

Conway's Game of Life is one of the famous uses of a cellular automaton. The rules for the Game of Life are very simple. To set up your game of life you'll need some initialisation rules, one for every cell you want to start live (we'll use black for live, and white for dead):

if x is equal to 4 and y is equal to 4 and state is new then state should be black

Add as many of these as you need for your starting pattern. Then add a rule, after all those:

if state is new then state should be white

I'll leave you to work out what the rules of life are for yourself, from the Wiki page I linked to.

CHEAT You'll find other rule sets you can explore if you go to the Parameters page.

Change the engine

If you want to modify the engine itself, you will need Leiningen 2.0 or above installed on your own computer, and you'll need to download the source, and unpack it.

You will find that there are three packages:

For each of these packages, you need to run, in the root directory of the package, the following command:

lein install

Once you've done that, you'll have everything built. To start a web server for the application, run the following command in the mw-ui directory:

lein ring server

Now you have it working, you can start changing things.

Add states

Adding new states is easy: just add new tiles in mw-ui/resources/public/img/tiles. The tiles should be png (Portable Network Graphics) files, and should be 32 pixels square. The name of the tile should be the name of your new state. It's good to also edit the file mw-ui/resources/public/css/states.css to add a class for your new state.

Change the code

Once you've done all that, you're ready to be really ambitious. Change the code. Implement some new feature I haven't thought of, or fix bugs I've accidentally left in.

You'll need an editor. I recommend either NightCode, which is quite small and will run on a Raspberry Pi, or LightTable, which is extremely helpful but needs a more powerful computer.

Worthwhile projects

If you would like to work on the engine, there's things that would be worth improving:

  1. Better arithmetic in actions
  2. Better arithmetic in conditions - it would be useful to be able to say 'if generation is more than 64 - y then state should be snow'. This would make the ice retreat in the right direction in the iceage rule set.
  3. Better error messages when rules don't parse, explaining where the problem occured (very hard).
  4. Make this all work in ClojureScript in the browser, so there's less load on the server and one server can support more users (quite hard).
  5. Optimisation: MicroWorld runs quite slowly, you can't really do big maps and one server won't support many users. There must be many ways performance can be improved.

If you make changes which you think improve MicroWorld, please mail them to me.

Have fun!

License

Copyright © 2014 Simon Brooke

Distributed under the terms of the GNU General Public License v2