-
Notifications
You must be signed in to change notification settings - Fork 2
Moniac
A simple prototype for an agent-based economic simulation framework.
We start with a simple world of 100 tiles arranged in a 10x10 grid (although topology is not yet significant).
Each tile can support a number of agents (typically humans) and provides a number of resources.
For our first scenario, we populate each tile with a Farm resource yielding 200 food units pa and a random population with mean 100. We assume 1 food unit feeds 1 population for 1 year.
We start with a very simple set of rules:
A small chance each tick for some population of each agent to die and a small chance for some to be born. The chance is taken from the UK's overall birth/death rate. As yet we do not track age so we directly modify the agent's population.
Each member of the population must eat some of its food reserves. If it can eat at the full rate it's happiness is 1 otherwise happiness is reduced by ratio of food available to desired.
If there is no food, the entire population of that agent starves to death.
TODO: if there is insufficient food, trade for more.
A Farm resource requires a certain number of workers to improve it and deliver a harvest. As a simple rule the Farm maintains a record of how much it has been improved each tick (ratio of farmers available to farmers needed). Once a year, the Farm pops a Harvest resource which is the production of the Farm multiplied by the improvement factor.
If a Farm is short of workers it can post a JobOffer on the Market noticeboard. Each other tile can bid to satisfy that JobOffer and send some of its spare population over as farmers.
When a Harvest resource pops it is immediately shared evenly with the entire population of the tile.
TODO: needs much realistic distribution - even Soviet collectivisation wouldn't achieve that!
The UI is very crude. Each Tile has a geometric shape that respresents it. Initially these are all squares and painted green. In the top left of each tile is shown the total population of that tile. In the top right of each tile is shown the average happiness of that tile.
Hovering over a tile shows more details in the panel on the right which shows each separate Agent and Resource.
A yellow line is drawn during the tick following any migration of populations between tiles (currently just those becoming farmers).
You can also pause and speed up / slow down the simulation rate.