Thursday, March 11, 2010

Ecomaker: Phase 1

For two days I locked myself in the house and lived off pop-tarts, soup and yogourt ('yogourt' is a funny word.) to put together the first phase of the evolution simulator thingy program.



Phase 1 just includes basic plants, herbivores and carnivores. The chain of life is simple; plants grow on their own, herbivores eat plants and carnivores eat herbivores. They go around on their simple lives, eating what is nearby and obeying a few other quirks I programmed in. If you have seen John Conway's game of Life, you'll have a basic idea of how my program plays out. Perhaps in the next couple days, I'll package and distrtibute the current version, so you can try it out yourself.

It's a fun program to watch (geekiness assumed) and all sorts of little patterns crop out.
The environment generally goes through seasons of plant dominance, herbivore dominance and then carnivore dominance. I didn't program in any "change season after x turns", so it was kind of interesting to see this emerge from the behaviors of the individual herbivores, carnivores and plants.
Against my intuition that the herbivores would congregate around plants, and carnivores just out of that range, the opposite wound up being true. Once a few herbivores start eating plants, the carnivores take over and the herbivores are the ones that have eaten their island of plants, so they hover away from the carnivarous commotion.
Another surprising thing cropped when I tried to make the program a little more efficient by making any plant become sterile if it tries to spawn, but fails to do so due to being completely surrounded. I thought this would hinder plant growth, but it actually boomed it. Basically, the lack of interior growth made for bigger inner-bush gaps that gave trapped carnivores more space to set up 'road blocks' that trap herbivores. Less herbivores, more plants. From this I learned why politicians are often corrupt. If even in a simple simulator like this, a simple change can have so many unexpected effects, imagine trying to run country. No matter what they do, something eventually blows up in their face, so they may as well screw everyone else over and make the best of it for themselves. Ya, politics from an ecosystem simulator!

Anyhow, for myself, the refresher in programming has been awesome. After doing about 15 pages of hand done code, I definately feel more confident in setting up, tweaking and debugging. I like to think that my code is actually good code, so integrating new features shouldn't be a monumental task. Making the SWING interface (the stuff that allows buttons, scrollbars, etc.) via NetBeans was easier than I expected, minus a few quirks. The basis of that editor is just drag and drop, then you just program in what the buttons and bars do on the back end. Hopefully my future programming will be a little quicker though.

On a final note, I setup my scanner and scanned a bunch of old map drafts I had in my schoolbooks (complete with the combinatorial mathematics I should have been paying attention to). I'll try and throw those up soon.

No comments:

Post a Comment