Tuesday, April 24, 2012

Unterholz



Unterholz is a particle based sandbox similar to the Powder Game. It uses Cellular Automata to calculate the water simulation and grow plants.
This game is built for LudumDare's 23. game development competition in around 12 hours.



The basic idea was to be able to influence the development of the environment through elements like wind and rain, and other influences like the sun, or its absence. The current functionality is limited to rain falling down and settling in lakes. Surrounding soil will consume water to become damp and have a chance of spawning a plant.


Eventually all environmental behaviors should only be minorly influenceable, like clouds forming automatically with the given circumstances, so it becomes more of a simulation than a sandbox.


Implementation

The current implemention is bruteforcing each particle to update each tick, uploading the image data for every single pixel. This is terribly inefficient and the simulation hits it's limit quite fast. Several adjustments need to be made for this to become stable and performant.

1. A major change should be a decently partitioned grid with Awake(regular updates), Idle(unreliable/irregular/occasional updates), and Sleep(no updates) states. Each state has a different update priority, so water that is settled once goes into Sleep, and will only be reevaluated if a neighbouring Cell's state is changed.

2. The image data needs to be stored in a buffer that is updated and changed throughout the update phase and just once uploaded. Several texture maps should be used for terrain, water, lifeforms (plants/critters).

3. For the sun to do it's magic i need to think of a way to calculate the lightmaps for the daycycle in a cheap but accurate fashion, so caves stay dark and cold while the surface might dry up.

4. Flow maps for heat and wind for generating cloud formations to make it rain and storm.

Pictured: Activity

Grow it big

More plants can be added with certain environmental prerequesites for them to grow, depending on the amount of light and space they have. Plants can range from algae to flowers to trees. The difficulty is making them appear distinct when only having pixels to work with.

Critters were planned to be added in the compo game. Time constraints didn't let me though. Life forms would be spawned near or in water, being fish or land dwellers. Fish would consume algae and produce offspring, their died bodies will be consumed by the earth leaving nurtured earth behind for better developing plants.
Land-dwelling critters would walk around eating plants or other critters, changing the ecosystem along the way.

This currently sounds like a big terrarium (i think i just got where Terraria got it's name from, duh :p) with only few interaction, so i am thinking about adding active players to the mix. They would be able to harvest, hunt, fish and transform the environment, actually impacting the whole ecosystem. When they block the sun and rain on a certain spot, plants will wither and leave dirt behind. Being too influential with your surrounding might end up tipping the equilibrium and you end up in a desert wasteland.

The most hi-res animation i ever made


What's the difference?

There is minecraft and it's horde of clones, Terraria and possibly more offspring in that genre, whatever those may be called. I really like both those games, and playing them extensively made me realize a thing or two.

The environments are very static. They can extensively be manipulated by the player, but if left alone nothing changes. A living environment would help to create a deeper atmosphere, seeing it developing on it's own and experiencing that your actions have consequences on your surroundings aswell.

Both those games have Biomes (fixed zones) to create more diversity to the environment. In Unterholz those biomes would be created dynamically, depending on rain, sun, clouds, wind, wildlife etc.

Although you can cultivate different plants in either game, the rules to do so are very vague. They need not to be irrigated or photosynthesize and have, apart from being resources, just an esthetic use. In Unterholz they would wither if being unattended for longer periods of time or would serve as food for wild life or else care for it's own business.


Why?

I got the original idea last Ludumdare compo where i built DiggyDig, a crude prototype of a pixel/image-based digging mechanic. Unterholz is in essence the logical followup to DiggyDig's mechanics. There's a third missing part for the general idea to be complete, but i might keep that for another time.
The idea now is to take what i learned from both and try to merge it into one interactive simulation and see what happens next.


You can download the compo version of Unterholz here.


1 comment:

  1. Wow well thought out. Love to see more! Keep it up :-)

    ReplyDelete