Recreating Sugarscape


2 Feb 2011

Introduction

I can't believe it's over a year since I last wrote about creating a Sugarscape simulation in Python and Pygame. The page attracted a fair number of views, but I suspect several visitors were looking for the teen magazine. However, at least some of the visitors were genuinely interested and a couple of weeks ago I was contacted by someone interested in recreating Sugarscape in Python. He sent me a link to a group at the University of Leicester who have also tried to recreate Sugarscape.

Sugarscape simulation

The University page has a lot of information about the original Sugarscape parameters, so when I got a bit of spare time, I decided to see if I could make a more faithful reconstruction of the original simulation. Perhaps because I already had most of the code, it didn't take very long. In fact most of my time was spent coming up with an equation to describe the elliptical maximum sugar levels (which still isn't quite right, but it shouldn't matter - one would hope the conclusions aren't so sensitive to the geography).

Simulation oddities

A few things surprised me about the simulation. Firstly, that there are only five concentrations of sugar (0-4), while my original simulation had 256. The advantage of having such a limited range, other than it makes it clear where the patches are, is that is creates terraces. Not sure how realistic this is, but it looks interesting. However, it does effectively doom any agent with a metabolic rate of 4, since they can only survive if they can find and secure a peak. These agents can also never collect more food than they start with, which means when reproduction is introduced, they will never reproduce, which seems a waste. In fact, it's highly unlikely that an agent with a metabolic rate of 3 or 4 will reproduce.

The second feature I found odd was that agents collect all the sugar from the point they occupy, but I suppose that this works given that the amount of sugar is limited to 4. Finally, I find it strange that agents can move the full extent of their vision (up to 6 squares) by tick, and this costs them nothing. This allows far-sighted agents to move very quickly across the world. At the very least I don't think agents should be able to move and collect food in the same tick, but then they would require a method of deciding whether to move or to collect sugar.

This final point relates to a problem that I had with the original simulation, which is that agents are given a random metabolic rate and range of vision, but there is no cost to having a slow metabolism or superior eyesight. I don't mind starting with a homogeneous population, but this situation seems particularly odd when evolution is added, because, clearly the population will simply evolve to have the best eyesight and lowest metabolism, which isn't a very interesting finding. A more interesting simulation would be to introduce a metabolic cost to having good eyesight. Which is something I can now try...

Comments (2)

Charlie on 21 Feb 2012, 11:52 p.m.

Are you planning to publish this as one of your programming projects - that would b really appreciated.

Thanks

Peter on 22 Feb 2012, 1:17 a.m.

I've thought about and would like to if I get some time. It's a project I go back to periodically. It's come on a bit further since I wrote, but not much.

I was hoping to add a few more features before I started writing about it again, and maybe switch to using Canvas so people can play with it online. But maybe I should just put the code online in the meantime, since it will take me forever otherwise.