Quantitative Spring Economics

Quantitative Spring Economics

Various things about Spring that do not fit in any of the other forums listed below, including forum rules.

Moderator: Moderators

squeakycleaners
Posts: 8
Joined: 06 Oct 2009, 03:49

Quantitative Spring Economics

Post by squeakycleaners »

I have been playing spring for a little while (BA, AA, XTA, CA) and feel it might be interesting to use the tools of science and mathematics to analyze spring phenomena and perhaps use this knowledge to improve strategies and techniques.

So without further ado heres my "mini-pseudo-academic" article :lol: :

Opportunity cost and its implications in spring:

In many TAS mods there are two resources: metal and energy. The extraction or synthesis of metal requires energy for each unit of metal extracted. Thus in economic terms, the opportunity cost of the metal is the amount of energy you expend to produce it. This opportunity cost varies with both the map geography and the tech level, so to simplify things I am going to assume that either the map is made of metal, or there is no metal at all. Having varying amounts of metal around will skew our calculations as then we will have to take into account the scarcity of metal at any given time. We will also assume that the capital cost (the cost to produce the unit) of the electricity and metal producers has been recouped. Finally, we assume that the player will build the unit with the best energy to metal conversion efficiency available. By adding the amount of energy required to produce a unit to the opportunity energy cost calculated from the metal required to produce the unit you get the price in the unit in EPU (energy price units), which for the conditions noted should be about the cost of the unit in terms of energy.

an equation for this is as follows
C = E + MC
C = cost of unit in EMU
E = amount of energy required
M = amount of metal required
C = amount of energy needed to produce one unit of metal

To calculate C, you take the energy used by the metal producer you will use and divide it by the metal produced by it.
For example: on a metalless map a metal maker uses 20 e/s and puts out 1 m/s
thus C = 20 e/m

Say you want to build a bomber that requires 200 metal and 6000 energy.
thus:
C = 6000 + 20*200
C = 10000

This means roughly, if your had 10000 energy and a bunch of metal makers already built, you can build 1 bomber.

This does not only apply to metal makers though, metal extractors use energy too.
For example:
Say your on a "metal planet" map and you build metal extractors that consume 5 e/s but put out 3 m/s.
thus M = 5/3
M ~= 1.67

The EPU values can be used to compare similar units to see which one is cheaper under a given circumstance. The power of using EPUs is that you compare one value instead of two. For example, you could compare the EPU/HP and EPU/defense strength of two units to find which one can soak the most damage for your money. You can do a similar comparison with EPU/Attack strength. One issue is that actual values for attack and defense strength are hard to come by. HP can be determined by simply recording the maximum number on the health bar on units.

Although the EPU analysis technique has weaknesses, it can still be applied to real scenarios. There are many battles that take place on metal planets and metal-less maps. Additionally, many energy and metal producing units, especially the level one units, cost relatively little and quickly recoup the capital cost. Recalculations of C can be made during battles to compensate for increasing tech levels, as more efficient methods of producing metal become available.

comments anyone? Anything that needs explanation? Also I would be interested to know if anybody experiments with this and has any suggestions.

Edit: fixed some mistakes in variables
Last edited by squeakycleaners on 07 Oct 2009, 02:57, edited 1 time in total.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: Quantitative Spring Economics

Post by Caydr »

People have been proposing formulas (firefox says "formulae" isn't a word) for units for a while now, it doesn't really work in any kind of real-world situation.

Also, TAS mods have 3 resources if you include time, which is more valuable than metal or energy. There are actually more like 5 resources in most situations really, but that's just my crazy-talk.
squeakycleaners
Posts: 8
Joined: 06 Oct 2009, 03:49

Re: Quantitative Spring Economics

Post by squeakycleaners »

I understand that but, I had to make many simplifications to make the problem manageable, hence, the two resources. In economics, many simplified models provide surprisingly useful results. I will admit, however, that I am an amateur in the field. I will also admit that much experimentation needs to be done.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Re: Quantitative Spring Economics

Post by Dragon45 »

0) infinite flat map
1) You have 1 kind of builder that can build solar and metal maker and more builders.
2) Everything costs X metal and Y energy and needs only 1 timestep/builder to complete
3) Solar is +0/+20 metal/energy per timestep
4) Metal maker is +1/-100 metal/energy per timestep
5) Builder can move anywhere from anywhere in one timestep
6) You start with 1 builder and 1000/1000 metal/energy

What do you build to maximize
1) Energy production?
2) Metal production?
3) Metal + Energy production?

after 1000 timesteps?

As you can see this is clearly a trivial framework made with a number of simplifying assumptions. Please let me know the outcome of your calculations.
Enjoy!

Hints:
http://en.wikipedia.org/wiki/Linear_programming
http://en.wikipedia.org/wiki/Discrete_event_simulation
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Re: Quantitative Spring Economics

Post by Dragon45 »

Okay, sorry for the previous caustic reply. You're obviously not a complete idiot. Try solving this simpler problem first:

1) You have 1 builder and 1 resource, money
2) Builder produces 100 money per minute
3) Builder can build other builders at cost of 100 money in one minute.
4) You can have as many builder as you want helping build any builder (makes the problem easier), time is proportional to num builders. F.ex 2 builder take .5 minute to build a builder, 60 builder take 1 second to build a builder.
5) Builder has infinite nano range.
6) Start with 1 builder and 0 money.

How do you maximize money after 100 minutes?
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: Quantitative Spring Economics

Post by Caydr »

Another scenario: You are in Las Vegas and need to get back to Canada before anyone finds the body. You have only $50, and a bus ticket costs $150. You can make money prostituting yourself at a rate of $20/hour, but buying makeup for $50 first will accelerate your prostitution gains to $35/hour. Wearing too much makeup can also be a dead giveaway to the police, and if you get caught you'll be at greater risk to being connected with the newly-rotting carcass in front of the strip mall. However, the local mafia don has narcolepsy and needs to shave before his meeting with the Dockworkers' Guild president. What is the fastest way to peel an onion?
YokoZar
Posts: 883
Joined: 15 Jul 2007, 22:02

Re: Quantitative Spring Economics

Post by YokoZar »

Dragon45 wrote:Okay, sorry for the previous caustic reply. You're obviously not a complete idiot. Try solving this simpler problem first:

1) You have 1 builder and 1 resource, money
2) Builder produces 100 money per minute
3) Builder can build other builders at cost of 100 money in one minute.
4) You can have as many builder as you want helping build any builder (makes the problem easier), time is proportional to num builders. F.ex 2 builder take .5 minute to build a builder, 60 builder take 1 second to build a builder.
5) Builder has infinite nano range.
6) Start with 1 builder and 0 money.

How do you maximize money after 100 minutes?
keep building builders until 99 minutes, then sit pretty
User avatar
hunterw
Posts: 1838
Joined: 14 May 2006, 12:22

Re: Quantitative Spring Economics

Post by hunterw »

most economy formulas fail as soon as they combine metal and energy in to a single variable when comparing costs. they are separate currencies. in situations where E is abundant and M is not, and vice versa, different units are more economical.

QUOTABLE BLOCK OF TXT BELOW FOR FORMULA THREADS!!!

look, the only portion of spring which can even be partially modeled formulaically is the economy, because when it gets to attacking units the number of variables goes through the fucking roof and the simulation becomes too complex to predict. now, with that said, one cannot simply expand their economy without investing in attacking units (yeah a couple exceptions, coop, etc). so every player, good or shite, must balance economic expansion with investment in attacking units - ones that return on investment by damaging the enemy. attacking units are a large portion of any economy, and since calculating return on investment of attacking units is too complex to ever predict, all this shit goes straight out the window.

the best spring players have no clue what every single unit costs, just like 99.99% olympic gymnasts have no clue about dynamic physics and the multitude of mathematical laws that govern their motion. it is a learned skill due to its inherent complexity.

we are not playing poker. spring cannot be beaten with math.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Re: Quantitative Spring Economics

Post by Dragon45 »

There's exactly one situation that can be modeled precisely and repeatably that is realistic - a player teching with a fixed amount of resources. If anyone actually has too much time on their hands, they should take try and figure out the optimal teching strategy for say with 3 mexxes and 1k/1k and starting with a single comm (this is the classic DSD tech). I think it would be perfectly possible to model that situation exactly.
YokoZar
Posts: 883
Joined: 15 Jul 2007, 22:02

Re: Quantitative Spring Economics

Post by YokoZar »

Dragon45 wrote:There's exactly one situation that can be modeled precisely and repeatably that is realistic - a player teching with a fixed amount of resources. If anyone actually has too much time on their hands, they should take try and figure out the optimal teching strategy for say with 3 mexxes and 1k/1k and starting with a single comm (this is the classic DSD tech). I think it would be perfectly possible to model that situation exactly.
meh, things like time to give orders, commander walk time, and even turn speed start to matter when multiplied over many minutes.

Better would be to just program multiple Lua-AIs to try different strategies and see which one hits the goal first.
User avatar
hunterw
Posts: 1838
Joined: 14 May 2006, 12:22

Re: Quantitative Spring Economics

Post by hunterw »

yeah if you do nothing but econ for like 5 minutes there is an absolute best way, but it's highly customized to each map. hell, each starting position.

here are just the MAP variables for best economy. metal patches, value and spacing, flat land availability (affects crane time, builder move time, as well as nano's value), flatten land time, E reclaimables, M reclaimables, geo spot(s), wind value, tidal value, water amount and location for building the tidals if so, etc etc.

all this shit gets so fucking complex. consider nano location for instance - for truly maximum value they need to be in a place which they can assist building the most important stuff (ie geo rush, or tidals, consideration to the nuke / plant you're rushing, etc etc), but this location may be out of the way of all builders at the most valuable time for them to be built. this isn't a slight variable either, movetime of construction units has a huge impact.

in conclusion, good fucking luck.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Re: Quantitative Spring Economics

Post by Dragon45 »

YokoZar wrote:
Dragon45 wrote:There's exactly one situation that can be modeled precisely and repeatably that is realistic - a player teching with a fixed amount of resources. If anyone actually has too much time on their hands, they should take try and figure out the optimal teching strategy for say with 3 mexxes and 1k/1k and starting with a single comm (this is the classic DSD tech). I think it would be perfectly possible to model that situation exactly.
meh, things like time to give orders, commander walk time, and even turn speed start to matter when multiplied over many minutes.

Better would be to just program multiple Lua-AIs to try different strategies and see which one hits the goal first.
You don't need to model all of that shit though. If you make simplifying assumptions (all mexxes in equilateral triangle, infinite build distance, etc) you could still get the optimal order in which to build stuff, in all likelihood. In general, these kinds of modeling problems do *not* require you to completely simulate all aspects of the situation, only enough so that the simplified simulation gives you an answer that's "probably super duper close".

Again, I'm saying: Find the optimal teching strat for exactly one map, one position on that map, assuming the enemy does not attack, and you don't need to worry about speed and nano distance.

There are standard methodologies for modeling error in these situations so it's not like you wouldn't be able to show in a reasonably rigorous way that you were probably pretty close.
User avatar
Carpenter
Posts: 216
Joined: 10 Jul 2009, 16:07

Re: Quantitative Spring Economics

Post by Carpenter »

squeakycleaners wrote:I have been playing spring for a little while (BA, AA, XTA, CA) and feel it might be interesting to use the tools of science and mathematics to analyze spring phenomena and perhaps use this knowledge to improve strategies and techniques.
Total geek.
User avatar
JohannesH
Posts: 1793
Joined: 07 Apr 2009, 12:43

Re: Quantitative Spring Economics

Post by JohannesH »

Dragon45 wrote:There's exactly one situation that can be modeled precisely and repeatably that is realistic - a player teching with a fixed amount of resources. If anyone actually has too much time on their hands, they should take try and figure out the optimal teching strategy for say with 3 mexxes and 1k/1k and starting with a single comm (this is the classic DSD tech). I think it would be perfectly possible to model that situation exactly.
Theres no optimal teching strategy unless you define a clearer gameplay goal.
User avatar
Otherside
Posts: 2296
Joined: 21 Feb 2006, 14:09

Re: Quantitative Spring Economics

Post by Otherside »

it all goes out the window depending on your enemy's actions you can give a very rough estimate at best
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: Quantitative Spring Economics

Post by TheFatController »

All you have to do is generate a giant minimax tree for BA, should only take a few billion years :)
BaNa
Posts: 1562
Joined: 09 Sep 2007, 21:05

Re: Quantitative Spring Economics

Post by BaNa »

this made me think of

http://blag.xkcd.com/2009/09/02/urinal- ... erability/


I disagree with the naysayers, imo there are certain ways to simplify even combat situations that lead to valid conclusions.

As for DSD speed-teching, its pretty much pat down by now, look at che rush adv. fusions...
squeakycleaners
Posts: 8
Joined: 06 Oct 2009, 03:49

Re: Quantitative Spring Economics

Post by squeakycleaners »

YokoZar wrote:
Dragon45 wrote:Okay, sorry for the previous caustic reply. You're obviously not a complete idiot. Try solving this simpler problem first:

1) You have 1 builder and 1 resource, money
2) Builder produces 100 money per minute
3) Builder can build other builders at cost of 100 money in one minute.
4) You can have as many builder as you want helping build any builder (makes the problem easier), time is proportional to num builders. F.ex 2 builder take .5 minute to build a builder, 60 builder take 1 second to build a builder.
5) Builder has infinite nano range.
6) Start with 1 builder and 0 money.

How do you maximize money after 100 minutes?
keep building builders until 99 minutes, then sit pretty
actually, you build builders for approximately 98.56 minutes. I am assuming that uncompleted builders can not contribute to building other builders. I think you assumed that this was not the case and that uncompleted builders could help, as when I did this I got exactly 99 minutes.

The math:
b = builders
t = time in minutes dedicated to building builders
m = money
(100-t) = time left after making all the builders

As we are at the beginning dedicating all of our resources to making builders, the number of builders doubles every minute as each builder is able to build one new builder every minute. Thus:
b = 2^t

When we are producing no more builders the amount of money we get is 100 (the amount of money per builder) multiplied by the number of builders we have (2^t) multiplied by how much time we have to rake in the money (100-t).
With this we get the equation:
m = 100*2^t*(100-t)

Now for optimization for how many builders we want so as to make the most money:

Differentiate the above equation with respect to t and get:
dm/dt = 100*{-(2^t) + (2^t)*ln(2)*(100-t)}

solving this equation for when dm/dt = 0 gives:
t ~= 98.5573

which by the way gives you about:

4.66343 * 10^29 builders
6.72790 * 10^31 money :-)
User avatar
JohannesH
Posts: 1793
Joined: 07 Apr 2009, 12:43

Re: Quantitative Spring Economics

Post by JohannesH »

squeakycleaners wrote:actually, you build builders for approximately 98.56 minutes. I am assuming that uncompleted builders can not contribute to building other builders. I think you assumed that this was not the case and that uncompleted builders could help, as when I did this I got exactly 99 minutes.

The math:
b = builders
t = time in minutes dedicated to building builders
m = money
(100-t) = time left after making all the builders

As we are at the beginning dedicating all of our resources to making builders, the number of builders doubles every minute as each builder is able to build one new builder every minute. Thus:
b = 2^t

When we are producing no more builders the amount of money we get is 100 (the amount of money per builder) multiplied by the number of builders we have (2^t) multiplied by how much time we have to rake in the money (100-t).
With this we get the equation:
m = 100*2^t*(100-t)

Now for optimization for how many builders we want so as to make the most money:

Differentiate the above equation with respect to t and get:
dm/dt = 100*{-(2^t) + (2^t)*ln(2)*(100-t)}

solving this equation for when dm/dt = 0 gives:
t ~= 98.5573

which by the way gives you about:

4.66343 * 10^29 builders
6.72790 * 10^31 money :-)
Carpenter wrote:Total geek.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Quantitative Spring Economics

Post by AF »

This is of use to AI development
Post Reply

Return to “General Discussion”