Author Topic: how do consumable resources work?  (Read 2630 times)

Zoythrus

  • Guest
how do consumable resources work?
« on: 21 October 2010, 04:12:27 »
im not too sure how they work. when i mean "work," i mean what's the process behind it all, because it doesnt seem right. i would expect a flow like what Spring has, but it's not like that. why not?

ElimiNator

  • Airship
  • ********
  • Posts: 3,391
  • The MegaGlest Moder.
    • View Profile
Re: how do consumable resources work?
« Reply #1 on: 21 October 2010, 06:24:28 »
im not too sure how they work. when i mean "work," i mean what's the process behind it all, because it doesnt seem right. i would expect a flow like what Spring has, but it's not like that. why not?
What are you talking about? If you don't "know" how they work then how do you know its not like spring?
Get the Vbros': Packs 1, 2, 3, 4, and 5!

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: how do consumable resources work?
« Reply #2 on: 21 October 2010, 07:12:53 »
im not too sure how they work. when i mean "work," i mean what's the process behind it all, because it doesnt seem right. i would expect a flow like what Spring has, but it's not like that. why not?

Consumable resources have an 'interval' parameter, this is the number of seconds (at normal game speed) between 'evaluations'. I just had a look at the code for this, and there is a very obvious bug in it... So, don't use two different consumable resources with different intervals... at least until 0.3.2 comes out ;).

If you want it to be more 'flow like' use a very small interval.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

Zoythrus

  • Guest
Re: how do consumable resources work?
« Reply #3 on: 21 October 2010, 14:02:54 »
hey, i just tested a hypothesis, and i found out that the system for consumable resources is broken. at one point, my resources were 20/60 (20), and it stayed there, never filled up to 60 (the refresh rate is 2 seconds). when i built a unit that cost 3 food, it changed to 17/60 (17); if this system worked right, it would be 20/60 (17). units should not pull out of the resource pile, only the income rate. when the income hits a negative number, the units should then pull out of storage. when the storage depletes, then they take damage.

get it?
« Last Edit: 21 October 2010, 18:35:53 by Zoythrus »

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: how do consumable resources work?
« Reply #4 on: 21 October 2010, 18:45:02 »
Please explain each of the numbers since I do not know what you have assumed them to stand for. Then give better details as to what you did and what you expected and what you saw.

Thanks

Zoythrus

  • Guest
Re: how do consumable resources work?
« Reply #5 on: 21 October 2010, 18:55:03 »
[amount of resources you currently               [amount of resources you can store (max)]                 [income of resource, how much
have (surplus resources)]                                                                                                       you should be getting per interval]
    
              10                                    /                              60                                                             (15)

in normal form, this would be 10/60 (15) [in case you hadnt figured that out]

when testing, i built a building which supplied me with 15 food, and stored 10. i was expecting 15 food to be put into storage every interval, but that didnt happen. the amount of resources stored (the first number) only went up when i built more of this building (15 was added because it makes 15 food).

i hope this makes sense to you guys....
« Last Edit: 21 October 2010, 19:03:52 by Zoythrus »

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: how do consumable resources work?
« Reply #6 on: 21 October 2010, 19:43:47 »
Confirmed.

Specifically, it stops adding resources at ('storage cap' - 'current consumption'), which is indeed incorrect.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: how do consumable resources work?
« Reply #7 on: 22 October 2010, 04:17:45 »
Fixed this in MG so that cap is not applied until after the resource numbers are crunched. Silnarm, what do you mean about the interval problem? I didn't see anything wrong with different interval values for multiple consumable resources?

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: how do consumable resources work?
« Reply #8 on: 22 October 2010, 10:04:36 »
Just to say it again:

the numbers shown are:  a/b (c)

where
a= the currently stored amount of data
b= the place to store the data
c= the income

the normal behaviour to calculate a was:
(a+c) modulo b - consume by your units. So I don't think its a bug that needs to be fixed!

What does it mean:
Lets say you have one farm. This farm can store 20 food. And you have 20 cows which all together produce 100 food and you have 50 workers which consume 1 food each.

This would result in the following display and I asume the workers start to die!
0/20 (100)

You might think this is wrong, but is it really wrong? The question is who is the final food producer? Is it the farm or the cow. In real life one farmer cannot have 1000000 cows and manage them! So although he has so many cows, he is not able to produce the corresponding food to his big number of cows! This is represented by the storage size of the farm in glest. A farm with its cows can only produce 20 food, no matter how many cows are running around or to say it more general ressources that you cannot store are lost and the consume is only done from the store.  Ok you might think this is a dumb behaviour because its just a game and not real life but if you change the behaviour you also change the game behaviour/balance at least a bit. So I think there is/was not really a bug or am I wrong?

But which way is it now softcoder, production - consume are used to calculate the store or what?

stored ressources=(production+ressources-consume) % store ?

 
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: how do consumable resources work?
« Reply #9 on: 22 October 2010, 14:04:30 »
a= the currently stored amount of data
b= the place to store the data
c= the income

'a' I can understand, I'm not convinced I understand your 'b' but I assume your mean the current total storage capacity for that resource by the faction, and I believe with 'c' you mean the 'balance' (positive meaning generating excess each interval).

This is enough confusion, I believe, to warrant not trying go on in those terms.

So,

 a = the amount of the consumable resource currently stored
 b = the maximum amount of the consumable resource the faction can currently store
 d = the amount of the consumable resource generated each interval
 e = the amount of the consumable resource used each interval
 c = the balance ( d - e )

the problem is that b is not enforced properly. If e is non zero, then the amount stored can not actually ever reach b, but only b - e.

Change food to <interval value='2' /> and watch... you can't reach them maximum storage unless you kill all units consuming those resources.

This is wrong, it is a bug, and certainly is not correct.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

Zoythrus

  • Guest
Re: how do consumable resources work?
« Reply #10 on: 22 October 2010, 14:34:02 »
personally, i have a different perspective of this all:

the units that consume should only influence the income rate, not the resources stored. Units should NEVER directly mess with the resources stored.

eg.
you build a unit that produces 10 food,
you then build a unit that consumes 4, making the income 6
you then build a unit that consumes 8 food, making the income -2
your food stored would then slowly deplete until it hits zero
if it hits zero, it will start to hurt your most consuming units first, then work its way down to your lesser consuming until it reaches equilibrium or a surplus.

right now, when you build a producer, it gives a small boost to the resources, and units take a small amount from it.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: how do consumable resources work?
« Reply #11 on: 22 October 2010, 16:16:38 »
Ok what we do in MG now is calculate tho final # (whether + or -) of used resources for this update cycle so the resource cap does NOT happen until we get a final #, then apply the final # to the store of the faction (which then caps to the max value). This means if you over-produce AND go past the store cap.. the store will be at 100% after the update (which i believe is correct behaviour and more like real life). Example:

I have 50 food, my store allows 100 max and I produce +51 each turn. After each update the store will be at 100 (where previously it would first go to 100, then tick down for all consumers so you could never be at full capacity. This is what I fixed and believe was wrong.

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: how do consumable resources work?
« Reply #12 on: 22 October 2010, 22:11:50 »
Fixed this in MG so that cap is not applied until after the resource numbers are crunched. Silnarm, what do you mean about the interval problem? I didn't see anything wrong with different interval values for multiple consumable resources?

Sorry softcoder, I some how missed this last night.  The problem is that Faction::applyCostsOnInterval() is called whenever an interval is up, any interval for any consumable.  This function takes no parameters, and updates all consumable resources without checking their interval.  So if you have food with an interval of 30 (as in magitech), and you add another consumable with a interval of 1, then food will be updated every second, along with the new one.

I just added a param to that call, so the signature becomes,
Code: [Select]
Faction::applyCostsOnInterval(const ResourceType *rt)Then in the World::processFrame() [probably World::update() in MG ??] the resource type who's interval is up is passed on, and only that resource type is updated.

Ok what we do in MG now is calculate tho final # (whether + or -) of used resources for this update cycle so the resource cap does NOT happen until we get a final #, then apply the final # to the store of the faction (which then caps to the max value). This means if you over-produce AND go past the store cap.. the store will be at 100% after the update (which i believe is correct behaviour and more like real life). Example:
...
Sounds good to me :thumbup:
Glest Advanced Engine - Code Monkey

Timeline | Downloads

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: how do consumable resources work?
« Reply #13 on: 22 October 2010, 22:50:03 »
Indeed, nice catch! If there were more than 1 consumable it would apply ALL consumables each update * # consumables which is bad. Fixed now in MG, thanks for the info Silnarm.

 

anything