|
22 Sep 2008, 01:53
|
#1
|
Commander in Briefs!
Join Date: Dec 2000
Location: UK
Posts: 783
|
Production Formulas
Now this is more of a help me i'm stuck question so this forum seemed more apt.
Could anyone help with the production formulas and produce a working line of code thats in either C++ or Delphi.
PU = (total_resources_spent^1/2)*LN(total_resources_spent^2)
PU Output = int(((4000 * # factories)^0.98) * (1 + (pop_bonus + gov_bonus + race_bonus) / 100))
Its just the ^ thats causing the problem, I know its to the "power of" but cant for the life of me figure out a way a programming language would calc it.
__________________
<Kila> WHAT HAVE YOU DONE WITH MY PRECIOUS FORUMS
<Zeyi> 24h forum closure
<Zeyi> all posts recalled
"he's got a proven track record when it comes to showy art composition" - Tommy
<Sigi> Light: can I ask u how many open internet-windows u always have?
<MrLobster|PM> i have 2, the pa page, and the website for naked light pictures
<Ave> both has bad gfx
|
|
|
22 Sep 2008, 02:42
|
#2
|
PA Team
Join Date: Apr 2004
Posts: 1,874
|
Re: Production Formulas
believe c and probably c++ as well has a function called pow.
say if you want 4^2, it be pow(4,2)
__________________
Requested: 1,000 kilometres of fulcrum cable, 1 Mark 5 ECM unit, one low yield nuclear weapon.
Purpose: Surprise party for foreign dignitary
|
|
|
22 Sep 2008, 03:06
|
#3
|
Commander in Briefs!
Join Date: Dec 2000
Location: UK
Posts: 783
|
Re: Production Formulas
Quote:
Originally Posted by Cincinnatus
believe c and probably c++ as well has a function called pow.
say if you want 4^2, it be pow(4,2)
|
Yep found that out by looking at some java script and then found the function in delphi.
floor( power( (4000 * 1), 0.98) * (1 + (BonusPU + Population.BonusPU)/100) )
__________________
<Kila> WHAT HAVE YOU DONE WITH MY PRECIOUS FORUMS
<Zeyi> 24h forum closure
<Zeyi> all posts recalled
"he's got a proven track record when it comes to showy art composition" - Tommy
<Sigi> Light: can I ask u how many open internet-windows u always have?
<MrLobster|PM> i have 2, the pa page, and the website for naked light pictures
<Ave> both has bad gfx
Last edited by MrLobster; 22 Sep 2008 at 03:14.
|
|
|
22 Sep 2008, 08:04
|
#4
|
mz.
Join Date: Aug 2005
Posts: 8,587
|
Re: Production Formulas
It is worth noting that this formula
PU = (total_resources_spent^1/2)*LN(total_resources_spent^2)
is terrible.
If you're planning on coding a production calculator, I would instead use
PU = (total_resources_spent^1/2)*2*LN(total_resources_spent)
These two formulae are equivalent, but evade the need for a ****ing gigantic variable to store total_resources_spent^2 in.
__________________
The outraged poets threw sticks and rocks over the side of the bridge. They were all missing Mary and he felt a contented smug feeling wash over him. He would have given them a coy little wave if the roof hadn't collapsed just then. Mary then found himself in the middle of an understandably shocked family's kitchen table. So he gave them the coy little wave and realized it probably would have been more effective if he hadn't been lying on their turkey.
|
|
|
22 Sep 2008, 11:59
|
#5
|
Commander in Briefs!
Join Date: Dec 2000
Location: UK
Posts: 783
|
Re: Production Formulas
i presume the 1/2 in the formula is 0.5?
__________________
<Kila> WHAT HAVE YOU DONE WITH MY PRECIOUS FORUMS
<Zeyi> 24h forum closure
<Zeyi> all posts recalled
"he's got a proven track record when it comes to showy art composition" - Tommy
<Sigi> Light: can I ask u how many open internet-windows u always have?
<MrLobster|PM> i have 2, the pa page, and the website for naked light pictures
<Ave> both has bad gfx
|
|
|
22 Sep 2008, 12:26
|
#6
|
mz.
Join Date: Aug 2005
Posts: 8,587
|
Re: Production Formulas
Yes.
It should be
PU = (total_resources_spent^(1/2))*2*LN(total_resources_spent)
or
PU = (total_resources_spent^0.5)*2*LN(total_resources_spent)
or
PU = SQRT(total_resources_spent)*2*LN(total_resources_spent)
__________________
The outraged poets threw sticks and rocks over the side of the bridge. They were all missing Mary and he felt a contented smug feeling wash over him. He would have given them a coy little wave if the roof hadn't collapsed just then. Mary then found himself in the middle of an understandably shocked family's kitchen table. So he gave them the coy little wave and realized it probably would have been more effective if he hadn't been lying on their turkey.
|
|
|
22 Sep 2008, 18:04
|
#7
|
CRASHING BEATS 'N FANTASY
Join Date: Mar 2001
Location: Cold Country.
Posts: 1,912
|
Re: Production Formulas
Let's also mention that the multiplication by 2 is much faster than calculating the power of 2.
__________________
Ià! Ià! Munin F'tagn! - [*scendancy]
|
|
|
23 Sep 2008, 07:14
|
#8
|
mz.
Join Date: Aug 2005
Posts: 8,587
|
Re: Production Formulas
I assume the same goes for sqrt( x ) vs. pow( x , 0.5 )?
__________________
The outraged poets threw sticks and rocks over the side of the bridge. They were all missing Mary and he felt a contented smug feeling wash over him. He would have given them a coy little wave if the roof hadn't collapsed just then. Mary then found himself in the middle of an understandably shocked family's kitchen table. So he gave them the coy little wave and realized it probably would have been more effective if he hadn't been lying on their turkey.
|
|
|
1 Oct 2008, 23:15
|
#9
|
The Original Carebear
Join Date: Nov 2004
Location: Trondheim, Norway
Posts: 1,048
|
Re: Production Formulas
Quote:
Originally Posted by Mzyxptlk
I assume the same goes for sqrt( x ) vs. pow( x , 0.5 )?
|
That depends, but normally it would be (Cheapass systems could translate the sqrt(x) call into pow(x, 0.5) thus making it slower, but most proper systems don't do that).
These details are so minor though, that you are unlikely to notice it unless you run a hundred thousand consecutive operations like that.
__________________
If at first you don't succeed, try, try again. Then quit. No use being a damn fool about it.
Oh crap, I might be back. I should take my own advice.
|
|
|
2 Oct 2008, 07:51
|
#10
|
mz.
Join Date: Aug 2005
Posts: 8,587
|
Re: Production Formulas
Quote:
Originally Posted by qebab
That depends, but normally it would be (Cheapass systems could translate the sqrt(x) call into pow(x, 0.5) thus making it slower, but most proper systems don't do that).
These details are so minor though, that you are unlikely to notice it unless you run a hundred thousand consecutive operations like that.
|
But really it's not so much about speed as it is about doing it the right way™.
__________________
The outraged poets threw sticks and rocks over the side of the bridge. They were all missing Mary and he felt a contented smug feeling wash over him. He would have given them a coy little wave if the roof hadn't collapsed just then. Mary then found himself in the middle of an understandably shocked family's kitchen table. So he gave them the coy little wave and realized it probably would have been more effective if he hadn't been lying on their turkey.
|
|
|
2 Oct 2008, 13:24
|
#11
|
The Original Carebear
Join Date: Nov 2004
Location: Trondheim, Norway
Posts: 1,048
|
Re: Production Formulas
Quote:
Originally Posted by Mzyxptlk
But really it's not so much about speed as it is about doing it the right way™.
|
The Right Way would be a formula that's easier to solve for total_resources_spent. Sort of hard for people to estimate, as it is now. If anyone wonders, the solution for total_resources_spent is (with total_re... = t and PU = p)
t = p ^ 2 / 16LambertW(-p/4)^2
Try to estimate that in your head.
PS! If anyone wonders why you would want to do that, it's to estimate how much you could spend in n ticks with m factories. So you don't screw up your spend before round end like mz did! (In like round 23 or something?)
__________________
If at first you don't succeed, try, try again. Then quit. No use being a damn fool about it.
Oh crap, I might be back. I should take my own advice.
|
|
|
2 Oct 2008, 13:29
|
#12
|
mz.
Join Date: Aug 2005
Posts: 8,587
|
Re: Production Formulas
Quote:
Originally Posted by qebab
The Right Way would be a formula that's easier to solve for total_resources_spent. Sort of hard for people to estimate, as it is now. If anyone wonders, the solution for total_resources_spent is (with total_re... = t and PU = p)
t = p ^ 2 / 16LambertW(-p/4)^2
Try to estimate that in your head.
|
We actually played around with that a bit about 6 months ago. x^x is a bitch to solve.
P.S. How about you help me find a closed form formula for this recurrence relation:
a(0)=1
a(1)=3
a(n) = 2*a(n-1)+a(n-2)
Quote:
Originally Posted by qebab
PS! If anyone wonders why you would want to do that, it's to estimate how much you could spend in n ticks with m factories. So you don't screw up your spend before round end like mz did! (In like round 23 or something?)
|
Would only help if you managed to actually remember how long the round was supposed to last though!
__________________
The outraged poets threw sticks and rocks over the side of the bridge. They were all missing Mary and he felt a contented smug feeling wash over him. He would have given them a coy little wave if the roof hadn't collapsed just then. Mary then found himself in the middle of an understandably shocked family's kitchen table. So he gave them the coy little wave and realized it probably would have been more effective if he hadn't been lying on their turkey.
|
|
|
2 Oct 2008, 13:32
|
#13
|
The Original Carebear
Join Date: Nov 2004
Location: Trondheim, Norway
Posts: 1,048
|
Re: Production Formulas
Yeah, the only really viable way of doing this is to use Newtons method or equivalent to find a reasonable approximation. Which isn't hard, but unnecessarily much work.
__________________
If at first you don't succeed, try, try again. Then quit. No use being a damn fool about it.
Oh crap, I might be back. I should take my own advice.
|
|
|
|
All times are GMT +1. The time now is 18:36.
| |