Archive for the ‘prototype’ tag
Well I’ve been wanting to do this for a while now, and on Sunday with a freshly installed (and therefore speedy) net book under my belt, I thought I’d have a crack at it.
Last year (maybe even 2 years now) ago, I made a weak plasmoid generator with the intention of using it for terrain generation. I’ve always wanted to use that library for some agent based programming, and a simple (rule wise) example of it would be water. You put some water agents on the map they move as low as they can go, then evaporate. This kind of does that, and definitely suffers from “proof of concept” syndrome. Water moves, but to do anything fancy will require redoing, which I’ll probably end up doing on my next free Sunday.
So, using a library called Gosu to handle the drawing and the event loop, and a library called TexPlay which allowed me to modify pixels, I got a render up and running which displayed a map of tiles (1 pixel tile ), and the colour was defined with a lambda that was passed to all of them.
As I’m learning Haskell at the moment, I thought I’d give some lambdas a go, and it made it really easy actually.
There are two types of agents in this program, Rain and Sources.
- Rain just flows to a low point.
- Sources make Rains.
Rains become sources if they hit a low point, which basically has the effect of stacking the Rains that have pooled there so they can make lakes. As Rains are destroyed when they stop, and Sources can only produce a finite amount of Rains based on how many are there when it is made, the system sort of stays constant. Initial sources are given enough Rains to cover the whole map 1 deep.
That is awkward to explain.
Most of the issues with this program was making the renderer fast enough to work on a net book, and as I’m not a graphics man, I made many rooky mistakes.
This is fairly mesmirizing to watch, and I’ll definitely improve it further, by:
- Making the map colouring sample from colour->height table
- Have water level as a tile attribute to make things cleaner
- Fix evaporation
- Make it so that tiles which have a constant flow of agents over them are distinguished from one-off “rain” paths
- Fix Rain
It’s a project, feel free to fork from git hub here at https://github.com/carl-ellis/Rain
Old school screen capture.
Video here: Rain – agent-based