Topics › Simulation

Simulating a demand curve

Recently, I've been watching the new microeconomics lectures at Khan Academy, which got me thinking about creating an economics simulation, something I've thought about many times. Specifically, I was wondering about how to come up with a reasonable demand curve. They always seem to be drawn as a straight line but with no justification other than simplicity.

Sugarscape with Canvas

Below is an implementation of the Sugarscape simulation I made using the HTML canvas. It shows a 50x50 grid with each square containing between 0 and 4 units of sugar represented with different intensities of green. There is an initial population of 200 agents (red circles) which move about and eat the sugar.

Pygame particle simulation in 3D

Below is a video of my first attempt to move my Pygame particle simulation into the third dimension (thus combining it with my Pygame 3D tutorial). I meant to write about it a while ago, but got distracted trying to work out how to display an image rotated in three dimension (for the walls). I still haven't worked it out.

Sex in Sugarscape

Since the last time I wrote about Sugarscape, I've made a bit of progress. The biggest improvement is the introduction of sexual reproduction. I can therefore recapitulate more of the results of the original simulation, and test a number evolutionary ideas.

Horse race gambling simulation

I listened to the radio this morning and the host was talking about the Grand National, which is today.

Sugarscape revisited

Screenshot of my Sugarscape simulation

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.

Hyphae simulation

I've started work on a simulation of fungus-like hyphae, based on project I saw called Mycelium.

Project:

Environment Simulation

A simulation of an environment and weather system in which cells might live.

Game of Life in one line of Python

This is my attempt at writing Conway's Game of Life in a single line of Python (an additional line is required to define the initial array, which is empty in my example, making the code even more pointless):

Solar system simulation

I was searching the net for physics simulations made in Pygame (scouting out the competition) when I found a gravity simulation. The simulation is very straightforward (and hence very good): it starts with some randomly distributed particles, which coalesce due to the force of gravity, often leading to some particles orbiting others. It is basically a simulation of how a cloud of dust can become a sun, or solar system.