Light Style© by Fisana

Jump to content


Photo

Renewable Resources


  • Please log in to reply
49 replies to this topic

#1 gudo

gudo

    Duplicarius

  • Community Members
  • PipPipPip
  • 239 posts

Posted 28 September 2011 - 01:36 AM

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.

Abstract:
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, 28 September 2011 - 02:12 AM.

  • 0
Did you contribute to 0 AD?
Make sure you're in the credits!


AI Players
JuBot | RootBot | SplitBot | qBot | Marilyn | arBot

#2 tribalbeat

tribalbeat

    Discens

  • Community Members
  • Pip
  • 89 posts

Posted 28 September 2011 - 01:53 AM

Sounds cool man.
  • 0

#3 edwardlongshank

edwardlongshank

    Discens

  • Community Members
  • Pip
  • 59 posts

Posted 28 September 2011 - 05:19 AM

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!
  • 0

#4 Pureon

Pureon

    Primus Pilus

  • 0 A.D. Art Team
  • 3,655 posts

Posted 28 September 2011 - 09:37 AM

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.
  • 0

Pureon
0 A.D. Part time Designer / Texturer / 3D Artist
Contact email:
pureon{@}wildfiregames.com


#5 edwardlongshank

edwardlongshank

    Discens

  • Community Members
  • Pip
  • 59 posts

Posted 28 September 2011 - 03:10 PM

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.
  • 0

#6 Jeru

Jeru

    Factotum

  • Web Development Team
  • 4,990 posts

Posted 28 September 2011 - 07:26 PM

in 0AD we spawn humans in 10 seconds...


And they pop out as adults!

We should add children to 0 A.D. if only as eye candy.
  • 0

Aviv Sharon [ aka Jeru ]

Wildfire Games 0 A.D. PR & Social Media Contributor
Contact me:
E-mail & Google Talk: aviv dot sharon at gmail dot com
MSN: lc_jerusalem at hotmail dot com
Facebook, Twitter, LinkedIn


#7 historic_bruno

historic_bruno

    Primus Pilus

  • WFG Programming Team
  • 2,485 posts

Posted 28 September 2011 - 08:09 PM

And they pop out as adults!

We should add children to 0 A.D. if only as eye candy.

Hmm I could see people getting very upset about children being killed if they are regular units :P Maybe if we have "animated" buildings, with people walking in and out, doing chores etc., then children could be included like props.
  • 0
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben [at] wildfiregames [dot] com

#8 ribez

ribez

    Duplicarius

  • Community Members
  • PipPipPip
  • 282 posts

Posted 29 September 2011 - 07:51 AM

maybe children could be taken as hostages, and, if they are not rescued from their original civ, as time goes they become soldiers and women of the other civ, but mantaining properties of the original civ
  • 0

#9 Jeru

Jeru

    Factotum

  • Web Development Team
  • 4,990 posts

Posted 29 September 2011 - 08:21 AM

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)
  • 0

Aviv Sharon [ aka Jeru ]

Wildfire Games 0 A.D. PR & Social Media Contributor
Contact me:
E-mail & Google Talk: aviv dot sharon at gmail dot com
MSN: lc_jerusalem at hotmail dot com
Facebook, Twitter, LinkedIn


#10 ribez

ribez

    Duplicarius

  • Community Members
  • PipPipPip
  • 282 posts

Posted 29 September 2011 - 09:09 AM

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, 30 September 2011 - 08:10 PM.

  • 0

#11 edwardlongshank

edwardlongshank

    Discens

  • Community Members
  • Pip
  • 59 posts

Posted 30 September 2011 - 05:40 PM

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.
  • 0

#12 AndreliusCaesarKhan

AndreliusCaesarKhan

    Tiro

  • Community Newbie
  • 7 posts

Posted 02 October 2011 - 03:47 AM

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


  • 0

#13 hhyloc

hhyloc

    Duplicarius

  • Community Members
  • PipPipPip
  • 244 posts

Posted 02 October 2011 - 04:33 AM

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, 02 October 2011 - 08:41 AM.

  • 0

#14 samgj

samgj

    Discens

  • Community Members
  • Pip
  • 23 posts

Posted 08 October 2011 - 12:56 AM

Rasprerries, lettace and bamboo would grow back in the time of a match, but two of those aren't in the game. Also children were in Warcraft 3, they could be killed.
  • 0

#15 SMST

SMST

    Triplicarius

  • Community Members
  • PipPipPipPip
  • 536 posts

Posted 08 October 2011 - 09:08 AM

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.
  • 0


Posted Image
Platon - it's like Communism without the noble goal.


#16 samgj

samgj

    Discens

  • Community Members
  • Pip
  • 23 posts

Posted 03 December 2011 - 01:53 AM

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.
  • 0

#17 fiasco

fiasco

    Discens

  • Validating
  • Pip
  • 43 posts

Posted 03 December 2011 - 05:15 AM

Please do not make the trees grow back...and do not make anything renewable for that matter (except farms) -- at least not in supremacy games. I will have nightmares if this happens.

Edited by fiasco, 03 December 2011 - 05:21 AM.

  • 0
Posted Image

#18 Thorfinn the Shallow Minded

Thorfinn the Shallow Minded

    Triplicarius

  • Community Members
  • PipPipPipPip
  • 494 posts

Posted 03 December 2011 - 09:30 PM

I disagree nearly completely, fiasco. I think that it should be an option for people to choose from.
  • 0
To win, we must endeavour to be the stronger of the two at the point of impact. Our only hope of this lies in making our own choice of operations, not in waiting passively for whatever the enemy chooses for us."—Schlieffen

#19 fiasco

fiasco

    Discens

  • Validating
  • Pip
  • 43 posts

Posted 03 December 2011 - 11:14 PM

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).
  • 0
Posted Image

#20 quantumstate

quantumstate

    Primus Pilus

  • WFG Retired
  • 1,150 posts

Posted 03 December 2011 - 11:44 PM

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.
  • 0

Jonathan Waller [ aka quantumstate ]

Wildfire Games Programmer
Contact me: jonathanmarkwaller at gmail dot com


Support Wildfire Games!