Discussion Income Algorithm for Summons in TW

Nestharus

o-o
Reaction score
84
So... how would people like an algorithm that perfectly did automatic income based on gold cost with possibility of override or putting in relative values with an operator? : )

The algorithm devised follows % per gold group methodology.

Let's say that the first summon is 5 gold for 1 income. That would mean for every 5 gold, you get 1 income (that's your base).

Now let's say that for every 5 gold, we only get out a %^i of that gold.

So with % of 95, the first summon would be (.95^0*5), which is back to 5 gold, divide by 5 to get income, so 1.

Now let's say the next summon is 10 gold. What would be the income?

(.95^0*5+.95^1*5) is 9.75.
R2I(9.75/5+.5) = 2

etc =). But wait... if you got up to like 70k, you'd get almost no income per 5 gold wouldn't you?

.95^13999*5 is virtually 0. Furthermore, the loop to construct the income would be ginormous O_O.

So, we place a group cap. 30 sounds good ^_^.

Now you would end up having 30 groups of 2333.3333333 instead of 14000 groups of 5 for 70k.

But then you end up capping out the income loss, so now we need to add one more factor. For every time a number can be divided by 5, we increase the number of groups for that thing by a %. 50% sounds pretty good as it won't cap out drastically, will allow income to go up and down (similar to tower wars games), and etc...


These numbers actually closely reflect a regular line tower wars game. However, the line tower wars game starts to deviate at around the start of shrine 2. Why? Because it's much more sporadic than the algorithm : P.


Now let's say we can also plug in initial values for unit types... and we can either make them relative or not and use an operator. Let's say we want the phoenix to be -30k income instead of +, like normal. We can override the value by just plugging it in = P.

Another way is let's say we want to decrease the overall income because it's an attack, like divide it by 2. Plug in 2 and set relative to DIVIDE. Done.


It took me many hours to figure out a great algorithm for tower wars in general, and this is the one I came up with. It can do decreases and increases and follows normal patterns. It can also do linear (group size of 0), meaning it's one group, like 100 gold would be 20 gold (100/5), or it can do always maxed, so 70000 gold would be 14000 groups instead of x groups.


Anyways I found this interesting and I'm wondering if something like this would be of interest to other people. It's purely mathematics, so it could easily be applied to SC2 as well ^_^.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
or alternatively players tl;dr a complicated system and want their simple system back?
 

Nestharus

o-o
Reaction score
84
or alternatively players tl;dr a complicated system and want their simple system back?

Actually, using a system like this would be very simple..

The ini itself is just 3 variables.


For overriding/relative setting, it's like...

Summon peasant = Summon['hpea'].get()
peasant.gold = 50
peasant.lumber = 1
peasant.relative = ADD


While the algorithm itself is a little bit complicated, it follows very closely to traditional tower wars = ). You have to do an algorithm like it to follow closely to tower wars.. if it's simple like linear, exponential, logarithmic, or well, just about anything, it'll fail. Believe me, I spent like 36 hours going through bundles of algorithms =P... well, only exponential and logarithmic algorithms, but =P.

Actually calculating the regression given values on a calculator gave me wrong algorithms, so I had to do it all by scratch o-o.
 

SerraAvenger

Cuz I can
Reaction score
234
You have to do an algorithm like it to follow closely to tower wars.. if it's simple like linear, exponential, logarithmic, or well, just about anything, it'll fail.

linear should be fine?
something like
0.05 + 0.95 * x/5 for x < 500
0.05 + 0.95 * 500/5 + 0.9 * (x-500)/5 for x < 2000
0.05 + 0.95 * 500/5 + 0.9 * (2000-500)/5 + 0.8 * (x-2000)/5
etc etc
I don't know the exact income, but with a couple of income groups this should work flowlessly.
 

Nestharus

o-o
Reaction score
84
Original values from line tower wars:
5-1
10-2
22-4
40-7
60-9
75-12
100-14
160-20
200-22
350-37
750-50
1000-100
4000-350
7500-625

Your values: (rounded)
5-1
10-2
22-4
40-8
60-11
75-14
100-19
160-30
200-38
350-67
750-143
1000-190
4000-725.05
7500-1245.05

My Values: (rounded)
5-1
10-2
22-4
40-7
60-9
75-11
100-13
160-16
200-19
350-35
750-79
1000-89
2000-182
4000-364
7500-686


winner: mine

as you see, mine can still be improved ; P. It's not perfect, but it's pretty darn good : D. Then again, the line tower wars values get pretty sporadic, so I'm thinking mine is probably a better curve than line tower wars. I used 1.25 as the group raise rate and 30 groups with base of 5 and .95 as log increase.

The group raise rate should have been like 1.3 I think. That poor 1000 : \... if I make it close, then the higher values are a bit too high etc (like 100-200 off instead of 36 off, lol) : (. I wonder how I should fix that, lol ,hm...

Oh, and as the values get higher, it gets a little more off. I 70000 is normally 3500, but mine says like 4500 or something I think. This comes from the fact that line tower wars values get very sporadic : P.
 

saw792

Is known to say things. That is all.
Reaction score
280
1.43216 - 5.38715/x + 0.116308 x + 0.000749362 x^2 -
8.88762*10^-6 x^3 + 3.31748*10^-8 x^4 - 5.16966*10^-11 x^5 +
3.42524*10^-14 x^6 - 8.20804*10^-18 x^7 + 5.979*10^-22 x^8

Rounding (not truncating...) the output of that will give you exactly the same values as LTW... except 75-12 is 75-11... Still, pretty good for only an 8th order polynomial :p.
 

Nestharus

o-o
Reaction score
84
1.43216 - 5.38715/x + 0.116308 x + 0.000749362 x^2 -
8.88762*10^-6 x^3 + 3.31748*10^-8 x^4 - 5.16966*10^-11 x^5 +
3.42524*10^-14 x^6 - 8.20804*10^-18 x^7 + 5.979*10^-22 x^8

Rounding (not truncating...) the output of that will give you exactly the same values as LTW... except 75-12 is 75-11... Still, pretty good for only an 8th order polynomial :p.

ok looking over it in a graph real fast o-o

Edit
Failure!!!

7500-7834
70000- too high to even do on calculator


It needs to be a single equation that works up to any number >.<.

Also, it doesn't look very easy to customize : (.
 

saw792

Is known to say things. That is all.
Reaction score
280
No, it doesn't fail. Your calculator fails. Mathematica > your calculator.
 

saw792

Is known to say things. That is all.
Reaction score
280
Calculators have limits. I know it's annoying, but evaluate each expression by hand. Or don't bother, since it will take you hours to do it well enough to avoid rounding errors/overflows on calculators.

Edit: haha my software failed me... it remembers old function results and outputs those instead. I'll make you a proper equation later :p
 

Nestharus

o-o
Reaction score
84
Actually, I was looking at the units and the values are all over the place because of special abilities o-o.

Here are values of all units without special things... it's much more linear, lol..

5-1
10-2
22-4
40-7
60-9
75-12
100-14
1000-100
10000-800
50000-3000


so it needs to be getting smaller as it goes up ^_-, so I believe it's logarithmic ; ).


-861.736686+233.968ln(x) is what I got on calculator, and it fails rofl.

I really think a series of polynomial expressions for every 5 numbers is probably the most accurate and powerful way to go though, because we must account for shrine differences and what not (y).

From there we must also consider the % change (p)

The base (b)


And from there, we must take into consideration special circumstance variables, like maybe attacker or fast unit =).

I guess I still have a lot of work to go on making this algorithm shiny and pretty : p.


edit
I had written out a bundle of stuff, but browser crashed so I lost it all.. : (

tier based on gold cost
x = 1000
i = 0

x /= 1.25^i++


To retrieve tier (1.25 being 25%)

From there-

.95^n*(1.25^i-1) where n is 0 thru 1000/(1.25^i-1)


edit
Ok so I changed the algorithm around and what not... the bottom reflect really well and I can make it so a few reflect quite well... but I'm still working on it...

hold on, here's the code thus far-
JASS:
struct aaaaa extends array {
    private static int groups
    private static int iterator
    private static real tierBase
    private static real tierCost
    private static real tierPercent = 1.4
    private static real goldPercent = .95
    private static real base = 5
    
    private static void onInit() {
        trigger t = CreateTrigger()
        
        TriggerRegisterPlayerChatEvent(t, Player(0), &quot;-&quot;, false)
        
        TriggerAddCondition(t, Condition(lambda bool() {
            int cost = S2I(SubString(GetEventPlayerChatString(), 1, StringLength(GetEventPlayerChatString())))
            
            real x = cost
            real curTierPercent = tierPercent
            trigger theLoop = CreateTrigger()
            
            if (cost &gt;= base) {
                tierBase = base
                
                loop {
                    x /= tierBase
                    exitwhen (x &lt;= tierBase)
                    tierBase *= curTierPercent
                    curTierPercent*=curTierPercent
                }
                
                groups = R2I(cost/tierBase) //ahhh!!! too many groups
                printf(I2S(groups))
                
                tierCost = Pow(goldPercent, groups)*((cost/tierBase-groups)*tierBase)
                
                TriggerAddCondition(theLoop, Condition(lambda bool() {
                    iterator = 60
                    do {tierCost += Pow(goldPercent, --groups)*tierBase}
                        whilenot (groups == 0 || --iterator == 0)
                    if (groups == 0) {return true}
                    
                    return false
                }))
                
                whilenot(TriggerEvaluate(theLoop)) {}
                printf(R2S(tierCost) + &quot; &quot; + R2S(tierBase))
                //printf(I2S(R2I(tierCost/base+.5)))
            }
            
            return false
        }))
    }
}



The groups are still skyrocketing too fast... 1.4 is perfect for the tiers... increasing it won't solve the group problem because then the tiers will be too far in between >.<.

So... any ideas on group problem?
 

SerraAvenger

Cuz I can
Reaction score
234
Your values: (rounded)
5-1
10-2
22-4
40-8
60-11
75-14
100-19
160-30
200-38
350-67
750-143
1000-190
4000-725.05
7500-1245.05

The numbers I gave were just examples.

With these numbers, it should be much easier to apply income:
5-1
10-2
22-4
40-7
60-9
75-12
100-14
160-20
200-22
350-37
750-50
1000-100
4000-350
7500-625
Just make multiple patterns,
like from 5-1 to 40-7; 40-7 to 100-14; 100-14 to 200-22; etc etc.

OUCH.
This is what my code generated:

Code:
m = case cost[I]
  when 0...60 then 0.200000[/I]
  when 60...75 then 0.100000[I]
  when 75...100 then 0.200000[/I]
  when 100...160 then 0.080000[B]
  when 160...200 then 0.100000[/B]
  when 200...350 then 0.050000[B]
  when 350...750 then 0.100000[/B]
  when 750...1000 then 0.032500[I]
  when 1000...4000 then 0.200000[/I]
  when 4000...7500 then 0.083333
  else 0.078571
 

Nestharus

o-o
Reaction score
84
....


that algorithm is epic failure -.-


If you have to plug in the gold costs, why even bother using an algorithm? -.-
 

SerraAvenger

Cuz I can
Reaction score
234
that algorithm is epic failure -.-

If you have to plug in the gold costs, why even bother using an algorithm? -.-

^^
I noticed lateron that it was linear only for the first 5.
However, you forgot something important.
a) Why have an algorithm in the first place, if plugging in the gold costs takes much shorter than thinking of the algorithm and the algorithm is even slower than a simple array read
b) The linear approximation might be "epic failure", as you put it, but it should show you something very important that could be vital to your nonsense-seek for an algorithm that successfully approximates the income in Traditional TW.
Just look at how m evolves. That's why I uploaded it. As you should be able to see, m is nothing but dincome/dcost -.- (man I feel so redundant having to tell you THAT). Now your "algorithm", which is in fact a function income(cost), needs to have this dincome(cost)/dcost.
I'm sure you know what that means.

PS:
You plugged in the gold cost for me =D
 

Nestharus

o-o
Reaction score
84
...

[ljass]printf(I2S(R2I(tierCost/base+.5)))[/ljass]


I translate cost based on tier and cost.... then I just get the regular income as you described -.-....

the problem, like I keep saying, lies in cost translation, more specifically, the total number of polynomials given a half translated cost.
 

Nestharus

o-o
Reaction score
84
Yes!! Methinks I did it!

5- 1
10- 2
22- 4
40- 7
100- 13
160- 17
200- 20
1000- 94
4000- 350
10000- 860 or so
50000- 4000 or so
100000- 7500 or so
1000000- 70000 or so
10000000- 139999 or so

Perfect? Yes! The income slowly lowers per segment of income as you go up, but the segment increase rate slowly lowers too! As you can see, it no longer jumps all over the place either, I got it pretty even.

Yea, it really isn't perfect yet, but I hope you can see precisely how accurate it is ^^. Now at one point it does go wildly off for the ltw map I was testing it in, but that's really because the ltw map went schizo.

It was like... 36000 for 3500 gold income and 70000 for 3500 and 50000 for 3000. See, schizo : p.


Anyways, I think this auto income algorithm I'm now using is going to be final ^_^. If anyone wants to use it for their summoning needs, let me know : p. As you can probably see, it follows a brilliant curve that reflects tiers and normal income loss. You can also set it to use complete linear or maxed out loss (maxed out loss not recommended unless you're planning a really short game o-o).

But yea, I'm proud ^^. You guys didn't help at all but we did get to talk and have fun : D.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top