Opened 11 years ago

Last modified 5 years ago

#1973 new enhancement

[PATCH] Regenerative resources

Reported by: alpha123 Owned by: Stan
Priority: Should Have Milestone: Work In Progress
Component: Simulation Keywords: patch design
Cc: Patch: Phab:D1718

Description (last modified by Imarok)

Some resources such as berries and fish should regenerate food so as to be more viable long-term food sources. This patch implements an extension to ResourceSupply.js to allow for regenerative resources and modifies the fish and berry templates.

A resource will start regenerating several seconds (controllable in the template) after its number of gatherers reaches 0. After that it regenerates at either a linear rate or using a population growth formula. Currently the way the formula works is that if you overfish and the amount of resources reaches 0, it will not regenerate. I couldn't tell if that was a bug or a feature, so I left it. ;P If it is a feature the fish should be removed from the map (currently regenerative resources are never removed).

Techs are supported, but in a rather unusual way: since the player is researching techs that apply to entities they don't own (gaia does) I had to implement it in a slightly roundabout way (thanks to leper on IRC). Basically, regenerative entities apply the techs of whatever player's territory they are currently in. This works fine for fruit, but not for fish since they won't usually be in anyone's territory. There are two tech modifiers: ResourceSupply/Regeneration/Rate and ResourceSupply/Regeneration/Delay.

Attachments (2)

regenerative-resources.patch (7.5 KB ) - added by alpha123 11 years ago.
regenerative-resources-v2.patch (11.5 KB ) - added by alpha123 11 years ago.
Change the formula for fish growth; clean some things up.

Download all attachments as: .zip

Change History (14)

by alpha123, 11 years ago

comment:1 by alpha123, 11 years ago

Component: Core engineUI & Simulation

comment:2 by sanderd17, 11 years ago

Looks nice, but the regen rate of the berry bushes is far too quick IMO.

10 women are not able to deplete 4 bushes. They regenerate faster than they can gather.

And about the fish, can't the exponential formula be applied by the amount of fish around in a certain range? So when you deplete some spot, but not another one nearby, fish will come back. If you deplete the entire ocean, fish won't come back. Of course, the regen rate should be slower when you check for more fish.

comment:3 by alpha123, 11 years ago

I turned the berry regen down a bit, I think it was very high from me testing it. :P

More importantly, I completely changed the formula for fish regrowth. It's now a simplified sigmoid curve. I can't claim credit for that though, thanks a bunch to scythetwirler on IRC for helping me out.

by alpha123, 11 years ago

Change the formula for fish growth; clean some things up.

comment:4 by sanderd17, 11 years ago

I just wonder, why all that juggling with timers?

You can simply take single setInterval timer. That also has a delay parameter. You simply start the timer (including delay) when the number of workers reaches zero. And each time the RegenerateResources function is executed, you check if the current number of gatherers is zero. If it isn't you stop that timer.

This would avoid subtile bugs with the timer.

Also, one timer every second would be sufficient (I think decimal amounts should be allowed, as long as they're rounded in the GUI). No reason to split it up between being integer or not. Just one call per second.

OTOH, I thought we discussed removing that delay timer (see http://irclogs.wildfiregames.com/2013-06-30-QuakeNet-%230ad-dev.log around 17:00) to avoid micromanagement, and just let regeneration start the moment some resources are taken, in which case the timer should be activated (if not existing yet) on every TakeResources call, and only cancelled when the amount equals maxAmount again

comment:5 by Kieran P, 11 years ago

Milestone: Alpha 14Alpha 15

comment:6 by wraitii, 10 years ago

Keywords: design added
Milestone: Alpha 15Alpha 16

comment:7 by leper, 10 years ago

Keywords: review removed

Removing review since this is mostly waiting on a design decision.

comment:8 by Michael D. Hafer, 10 years ago

Milestone: Alpha 16Alpha 17

comment:9 by leper, 10 years ago

Milestone: Alpha 17Backlog

comment:10 by leper, 9 years ago

Owner: alpha123 removed

comment:11 by Imarok, 5 years ago

Component: UI & SimulationSimulation
Description: modified (diff)
Milestone: BacklogWork In Progress
Owner: set to Stan
Patch: Phab:D1718

comment:12 by Imarok, 5 years ago

Move tickets to Simulation as UI & Simulation got some sub components.

Note: See TracTickets for help on using tickets.