food chain simulation

Community Forums/Showcase/food chain simulation

Drak(Posted 2008) [#1]
A simple media-free program I created for fun. 4 types of life struggle to survive in this program. Plants try to grow and reproduce. Insects try to eat the plants. Mammals eat the insects. Carnivores eat the mammals! All 4 types look for food on their own and reproduce when conditions are right for them. Note: This program requires no input from the user, altough you CAN add some plants and insects to the program if you wish.

Instructions:
ESC key quits.
Hold i key to add insects... (this is keydown, not keyhit, so be careful not too add thousands on accident)
Press p key to add 1 plant.
You should not have to add anything at all, actually.

Edit:
I forgot to mention.. Plants are green, insects white, mammals grey, and carnivores are red, in case anyone was wondering.

Here is the link: (613 kb)
http://www.mediafire.com/?yxdyfj4uyfp


chwaga(Posted 2008) [#2]
very cool!


GIB3D(Posted 2008) [#3]
Lol, on my second simulation I just left it alone and they all died off in, I think, less than 5 mins.


Retimer(Posted 2008) [#4]
Kazillion inects just swarming the hell out of the plants lol.


Drak(Posted 2008) [#5]
Lol, on my second simulation I just left it alone and they all died off in, I think, less than 5 mins.


Aye, I've run it dozens of times for testing and the results are always drastically different. I've seen all the insects get eaten within 30 seconds of starting. It all depends on how each lifeform thinks.

Each creature is given randomly generated "wants" when it born. Some will find mating more important than eating, some will eat rather than mate, a few will just sit and do nothing, some will wander around aimlessly. Most will behave normally as one would expect, though.


M2PLAY(Posted 2008) [#6]
Ohhh very interesting stuff !!
thanks


TaskMaster(Posted 2008) [#7]
This is cool. Can you make it run in a Window so I can leave it running and still work?


Drak(Posted 2008) [#8]
This is cool. Can you make it run in a Window so I can leave it running and still work?


Of course I can. The only thing is, the chain will eventually break itself at some point, in which case the whole "world" suffers and eventually die out. I have some optimizations I want to complete and also a few other choices for each species I want to implement as well. For example, I'm working on getting the mammals to also eat plants when the insect population gets too low. I'm having a lot of fun with this program so hopefully it won't take me too long.


GaryV(Posted 2008) [#9]
I like this, but it would be more fun if we could experiment with the code of this little ecosystem to see how much we can warp it.


Stevie G(Posted 2008) [#10]
Nice.


Raz(Posted 2008) [#11]
Hey nice one :D

I might have a play tomorrow and try something similar.


deps(Posted 2008) [#12]
Mammals eat insects? I thought they only ate plants/grass/vegetables/fruits/etc?


GaryV(Posted 2008) [#13]
Mammals eat insects? I thought they only ate plants/grass/vegetables/fruits/etc?
you are a mammal. Do you only eat plants? Not all mammals are herbivores, some are carnivores, some are omnivores, some are frugivores and some are insectivores, etc.


Drak(Posted 2008) [#14]
Mammals eat insects? I thought they only ate plants/grass/vegetables/fruits/etc?


This is the first link I found:
http://kids.yahoo.com/animals/mammals/mammals-eat


chwaga(Posted 2008) [#15]
lol, yeah. Mammal just means it doesn't lay eggs


deps(Posted 2008) [#16]
Oh, right. silly me. Carry on then. :)


Zenith(Posted 2008) [#17]
Nice job! Now all you have to do is add a genetic code, and you'd have the makings of a nice evolutionary sim! ;)


Buggy(Posted 2008) [#18]
@chwaga, both the echidna and the platypus lay eggs.

@Drak, awesome. Why not try making the mammals run away from carnivores? Or even fight back when in large numbers? Could be interesting...


Drak(Posted 2008) [#19]
@Buggy, I like the idea of mammals fighting back if the numbers are big enough. I may have to try and implement this. As far as running away goes, this will take some code tweaking. In the current version, mammals are always faster than insects, and carnivores are always faster than mammals. However, if I were to implement some genetic code... the mammals that were faster would live longer, and their children would also be faster than other, slower mammals. That's natural selection right there.


*(Posted 2008) [#20]
you also could make it that mammals have to seek out another mammal to mate this would mean that they would clump together more and form groups.


Yahfree(Posted 2008) [#21]
This would make a good screen saver