Jump to content

Renewable Resources


Recommended Posts

Renewable resources has been discussed before here, but I want to bring it up again and in more depth. Even discussion on whether or not it's a good thing to include is welcome.Specifically, I want to discuss ways it could actually be implemented. I have an idea of my own that I've drafted up, but would love some comments on it.


This is a rough writeup of my proposal to create a more dynamic natural world. In short, we create an AI for gaia. The AI will spawn units and trees in as realistic manner as possible, and control the movements of animals to simulate their natural behavior. The goals of this project are twofold:

*Renewable Resources - Gaia will spawn animals and trees in a reasonable manner. Logged forests should eventually regrow, and animal populations should eventually recover from hunting (assuming there's any left).

*Realistic Animal Behavior - Lions should hunt deer and travel in packs.

This post will focus on first part.

Step 1: GUI Support for a Gaia AI

Gaia is already allocated a player id, so we can just create an AI that does everything we want Gaia to do, and assign it to control Gaia. At a minimum, we could just assign it to be the default AI and leave it at that. (see /mods/public/simulation/data/player_defaults.json)

Preferably, there'd be a way to assign/unassign an AI to Gaia in game. I'm thinking a check-box "Active Gaia" by "Reveal Map" and "Teams Locked" in the game creating screen. Checking the box would assign GaiaBot (or whatever the AI is called) to Gaia, and unchecking it would unassign Gaiabot. Default behavior would be unchecked, or "off." As an additional consideration, GaiaBot would somehow have to be concealed from the players, lest the accidentally assign it to play a real civ.

We would then write the bot to do whatever actions we wanted Gaia to do.

Step 2: Establishing Population Limits for Fauna

We can't spawn fauna simply as a fraction of the existing fauna. While it would lead to exponential growth (which we expect to see in real populations) we run into the problem of maximum population. Growth that's proportional to existing population simply never quits growing. Having 2000 deer on your map would certainly cause performance problems. Additionally, in the real world, there's a finite amount of resources available for population growth. Our GaiaBot will need to establish population limits and use equations to control growth in such away as to not violate those limits.

Further down in the thread, I will post a brief overview of mathematical population modeling and link it here for those interested.

Step 2.1: Population Limits for Fauna

2.1.1 Possible Exceptions

GaiaBot will not compute population limits for Fauna with the parent template "template_unit_fauna_herd_domestic"

Population Limits for predators would initially depend on the number of prey. Later, once the bot is more sophisticated and can have predators actually hunt, the population limit will be based off the kills they make.

2.1.2 Calculating

It is up the map creator/RMS to decide what constitutes a reasonable number of animals for a given map. As such, at the start of each map, as it's first action, GaiaBot will simply count each animals of a given type. That value is then stored as a variable limiting the population of each animal of that type, i.e.

var deerpopcap = (relevant code); //The population cap for deer.

Step 2.2: Establishing Population Limits for Flora

2.2.1 Possible Exceptions

GaiaBot will not compute population limits for Flora that provide food (berry bushes, apple trees)

2.2.2 Calculating

Once again, we leave establishing a reasonable limit to trees to the map creator/RMS. However, GaiaBot doesn't care about the type of tree. We simply tally the total number of trees and store it.

Step 3: Establishing Growth Rates

For a somewhat in-depth analysis on why these formulas were chosen, see my later post on modeling populations.

For both flora and fauna, the growth rate is:

Rate of growth = k(Pop)(1-Pop/Cap)

Where Pop is the current population of a species and Cap is the population cap for that species (i.e. deerpopcap)

k is an arbitrary constant that is used to fine tune the rate. If we want something to spawn faster, give it a large k. (note also that a sufficiently large k could shoot a population over it's population limit. This would cause a die-off.) We can add terms to this equation if we like, to simulate say, a threshold for survival (if the population ever falls below said threshold, we slowly go extinct.)

After inputting the proper values for each species, we add the result to another variable (continuing with deer as an example, we'll call it deergrowth) which will then be used to determine how many we spawn. "deergrowth" holds the fractional remainders of previous operations, so we don't loose, say half a deer.

Say for example, we've been running GaiaBot for awhile and deergrowth is == .53. After running a rate of growth calculation for deer, we get a result of 4.32. This is then added to deergrowth for a total of 4.85.

Step 4: Spawning Entities

Step 4.1: Spawning Fauna

Let's do an example:

Our deergrowth variable is at 4.85. GaiaBot will then choose 4 random deer and order each of them to train one more deer. 4 is then subtracted from deergrowth. Placement of the new deer will obey the spawning code set up for <TrainingQue> (that is to say, it will be adjacent to the animal and will respect passability class.)

We'll have to add the <TrainingQue> tag to each class of fauna, with the ability to train itself (I've done a quick and dirty hack with deer, it works.)

Step 4.2: Spawning Flora

Regarding the number of flora to spawn, it's easy. If, say treegrowth == 2.34, then we spawn 2 trees. As far as the placement is concerned... I'm not so sure that <TrainingQue> is the best way to do it. Eventually, we'd wind up with dense, impassible forests. For some maps, this might be just fine. For others, not so much. Perhaps we could do it by tree type? Evergreens, say would use <TrainingQue> resulting in thick, dense pine forests. Palms would use some other method.

Step 5: Additional Features

Currently, players can't order fauna to move (meaning Gaia can't order Fauna to move.) There needs to be a way for Gaia to do this. According feneur, players will need to be able to order animals around, so it's a needed feature anyways.

Comments on Sections

1: Philip tuned me on to other ways of spawning units in game (scripted system component to be exact) but as the eventual goal of my proposal also requires moving animals, I think AI would be the best way to do it. Also, this seems to be the way requiring fewest changes to existing code. In fact, only the game setup screen should need changing (oh yeah, and all the gaia templates. Still possibly simpler than adding a new component.) Disabling renewable resources would also be a synch.

2An alternative method for generating population limits would be to have them specified by the map designer or RMS and stored in the map file itself. This would make the bot simpler, and allow the map maker slightly more control.

2.2This assumes we regenerate flora. Maybe growing trees back is too game breaking? That's the whole point of the thread! Also applies to 4.2

Edited by gudo
Link to comment
Share on other sites

I think its a good idea.

The main problem i have with your idea is that because the maps are not very large and the human population on the map can grow to such a great number i think it would be extremely difficult for the natural environment to be able to recover in the relatively short space of time that o ad covers especially considering that after a lot of the the trees are cleared they will be built over and animals will have houses and farms built in there environment. The impact Ancient Super powers had on the environment was both devastating and unique in that never before had there been such a huge increase in both human population concentrated with in small areas and advancements in effectiveness of tools to gather large amount of resources in a short period of time. I say super powers instead of World super powers because although i am talking about civilizations like Persia and Rome which were both World superpowers, superpowers like Mesopotamia and Egypt also fit into the same category of being environmental devastators. Usually once an area becomes heavily populated with humans the natural resources are completely abused and striped away to then make room for more effective means of producing food. It would be another 1500 years before the full affects of this recklessness started to become apparent and another 500 years after that before we gained somewhat of an understanding of most of the consequences of it. Ok sorry i got a little of topic towards the end there.

Anyways if you can find out some facts on just how long it took for trees/forests and wildlife to recover and if they did in fact recover at all during the time period we are talking about then that would help sway my decision. And remember i don't actually know much about ancient history so if your planning on using any of my info in anything then double check it first!

Link to comment
Share on other sites

gudo I fully support your initiative here.

Renewable resources become functional for those of us that enjoy slower games. It's not just the functionality that renewable resources provide, your proposed system provides a deeper game experience by creating a living, growing environment. Brilliant for immersion.

@edwardlongshank's comment about how long it takes for resources to replenish - I don't think we should worry too much about 'time' - in 0AD we spawn humans in 10 seconds...

Regarding where flora and fauna spawn - it should probably be in places away from human activity. Perhaps trees only grow back in place of trees that were previously cut, unless the spot is being used for something else now. I'll think about it some more.

Link to comment
Share on other sites

I think regardless of time its unrealistic to have forests regrow when ever scrap of wood is being collected to build huge navy's and buildings. Once a forest is gone then its gone for a very very long time ( thousands of years), especially when there's likely to be temporary/permanent roads being built over the deforested area. I would love to be proved wrong so if anyone has any facts that go against what i say please let us know.

Link to comment
Share on other sites

No death animation for children in 0 A.D. They shall be immortal. Or just magically disappear at 0 HP. :P

(And I, for one, really would rather not integrate them into gameplay)

with my proposal nobody can kill them ;) : they grow and became soldiers/women with their original civ or with the civ that take them as hostages

Edited by ribez
Link to comment
Share on other sites

I think children should be represented as *available population*. By that i mean you have a population of children which players cant interact/move/control and the children are available for *training*. Once they are trained they are then controllable by the player ( same as it is at the moment) and they then fall into a different population called something like *working citizens* or maybe *Working Adult population*, it would probably depend on the faction. These adult workers should probably also be paid and fed until they are killed unless the player runs out of resources in which case the soldiers should slowly weaken until the player is able to feed/pay them again. If the player is unable to feed them for a very long time then they should either die or desert. The player should also have the ability to *retire* soldiers so then the player does not have to support ( feed and pay) as many soldiers. The player should also get a very small reward for each soldier he retires to encourage players to retire there unwanted soldiers instead of just *suicideing* them into the enemy as it has been done in i believe all or most rts games.

Link to comment
Share on other sites

Going back to the topic of the post, I think the ability to have trees grow is a very great idea, and has been done before in other games successfully (like stronghold) at a very slow and steady pace- which doesn't really disturb civilization growth, since trees are easy to cut down if you simply get a huge army of soldiers to cut them down.

I am interested though about what can be done to aquire more stone and metals in the late game when resources get really scarce, as having rocks and metals "grow" doesn't make much sense. lol

Link to comment
Share on other sites

As for rocks and metals, we can have a "mine field" to complement the renewable resources idea, the player can build upon them a building and garrison citizens inside to mine. The mine will have limited resource but it will slowly replenish overtime (mimics the way miners dig deeper and deeper for minerals)

For faunas, may I propose a new type of neutral building: Den (Lair). The Den AI will automatically spawn animals in their respective type (Lion Den, Bear Den,..) but with a limit in population and frequency and blahblahblah many other aspects like gudo has pointed out. For herbivore animals (Deer, Giraffe, Elephant,...) they'll have to "train" their offsprings without a den ( same to many animals native to Africa).

Edited by hhyloc
Link to comment
Share on other sites

Maybe there could be stumps added in places where deplenished trees stood. This would be a good indicator for a player to see where trees will eventually grow back. (if not blocked by something else)

As for Metal, Empire Earth solved it in a way that there were mines with a(practically) infinite amount of ressources, but with a limit of people mining. Maybe that would be something to think about.

Link to comment
Share on other sites

  • 1 month later...

I don't think trees should grow back, the matches feel like they last a few days, like real life battles. I also think metal should be plenty rather than renewable but maybe we could create a systen to simulate recycling, such as metal is gained when you kill enemies, with armored unit giving more metal.

Link to comment
Share on other sites

I disagree. An RTS-game is about managing your resources well -- a decent player will either win or lose well before resources run out in a supremacy game. If there are ranked games implemented on multiplayer for example, then renewable resources should not be allowed. And since when does a tree grow back in 30 minutes anyway (if a game lasts that long).

Link to comment
Share on other sites

I think it is nice to have some kinds of renewable or extremely long lasting resource. It allows people to play more defensive strategies and I always think it is better to allow more strategies for more varied games. A lot of rts games have a system like this, in AOE2 it was food and wood (on most maps) and gold if teamed, AOM and AOE3 had food and gold, C&C generals had an infinite resource generator for each civ. It is key that these methods are all less desirable than expanding and collecting around the map so that there is incentive to expand.

I think we need to aim to limit players by gather rate not have an absolute cap, so then you can choose to spend more time gathering lots of resources or more time fighting with your troops to use the resource cost effectively. Having slow infinite resources means that you still have to be careful with the initial fast map resources because if your opponent still has lots of fast resources from that you will be at a big disadvantage.

Link to comment
Share on other sites

I think we should aim for an average game length that doesn't include deforesting the entire map. :) There is also trading and bartering for the late game econ. (y)

Yeah, and I remember when playing AoK that even if I had deforested the entire map etc, I rarely used even close to all those resources (as you may guess I enjoy playing defensively ;) And basically wait until the AI was already defeated before attacking =) ). It might be fun for some people/in some cases if there is a gameplay mode with renewable resources, so I'm not against it completely, but I don't think it should be the default.

Link to comment
Share on other sites

Funny, the same discussion with similar conclusion is in Warzone2100 forums.

My opinion is that there should be renewable resources, at least when it comes to wood (because iron and stone is irrelevant). trees that will grow randomly over time will add to the game atmosphere and enrich it. However, if programming it is complicated, it's not that important to implement.

Link to comment
Share on other sites

I don't think it makes sense to have renewable resources if the game doesn't last long or cover that great of a time period per match

but an idea fo rit anyway: What if herds of deer just randomly come out of the fog in a big forest, onto grassy fields.

and i don't think lettuce counts as food that would really make a meal :P

Edited by Centurion
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...