• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Maths] trying to create a formula for an increasing value

Status
Not open for further replies.
Level 6
Joined
Jan 8, 2009
Messages
140
wasn't really sure how to word the title or if it even makes sense lol. I have 3 values and want to make a fourth value based on the other three. the three are max mana, max hp and level. I want to be able to derive a value from these attributes combined that will increase in an exponential manner. I've tried a few basic ones in excel but using my limited maths ability can't really create values that do this.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
there are a ton of formulas you can use like this one.

This is the fibonacci sequence. Which adds the number before and at the previous to get the next number.

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377

Example use an array then a loop integer.
loop through and to get the next number you simply take number at previous and number at loop integer add them together then place them in the next array index.

If this is not what you want try explaining in more detail.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
If you give us more of a sense of what kind of output you're looking for depending on the other 3 values and their weights, we can do some derivatives to figure out the rate of change and then integrate the whole thing to give you a spiffy equation : p, either that or we can plug it into a site that'll do all of that for us >.<
 
Last edited:
Level 6
Joined
Jan 8, 2009
Messages
140
there are a ton of formulas you can use like this one.

This is the fibonacci sequence. Which adds the number before and at the previous to get the next number.

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377

Example use an array then a loop integer.
loop through and to get the next number you simply take number at previous and number at loop integer add them together then place them in the next array index.

If this is not what you want try explaining in more detail.

That's sort of what I mean, but isn't that preset values?
 
Level 6
Joined
Jan 8, 2009
Messages
140
No like i said you can find them out with a loop

Example:
  • Set IntegerArray[0] = 1
  • Set IntegerArray[1] = 2
  • Set length = 100 // Or whatever you want
  • For each integer tempInteger from 1 to length
    • Loop
      • Set IntegerArray[tempInteger + 1] = IntegerArray[tempInteger - 1] + IntegerArray[tempInteger]

I don't quite understand how this applies to finding out the value I need. let me try explaining again. Using some combination of health, mana and level I want to create a real or int value which I can use in other systems that adapt to how this value (and others) change. It's a part of the difficulty scaling i'm working on for my map.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
It is all on how you want the numbers to end up. How big your mana can be and how high your health can be. Along with level and what outcome you are expecting to be between certain numbers like to fit in an array. Best thing to do is mess around with a few simple formulas and then you may find something suitable.
 
It really depends on for what youi are using this value..

Yes, with (HP+MP)/2 sounds not bad, but for example something like (HP+MP)*(HP+MP) would be more balanced.
In my example you need to get equality of bot to achieve larger value, fixing on only one of these would not be best.

Then " * Level" also doesnt seem really good to me. Look at what happens if you compare these:
Level 1 <=> Level 2 --> value gets x2.0
Level 10 <=> Level 11 --> value gets x1.1

So after some levels the level factor wont cause any big changes anymore.

I suggest you to work with a constant here, and only add the value, not multiplying it, .. + (Level * 1) for example // 1 is your constant
 
Last edited:
Level 6
Joined
Jan 8, 2009
Messages
140
It really depends on for what youi are using this value..

Yes, with (HP+MP)/2 sounds not bad, but for example something like (HP+MP)*(HP+MP) would be more balanced.
In my example you need to get equality of bot to achieve larger value, fixing on only one of these would not be best.

Then " * Level" also doesnt seem really good to me. Look at what happens if you compare these:
Level 1 <=> Level 2 --> value gets x2.0
Level 10 <=> Level 11 --> value gets x1.1

So after some levels the level factor wont cause any big changes anymore.

I suggest you to work with a constant here, and only add the value, not multiplying it, .. + (Level * 1) for example // 1 is your constant

I don't get why the level would cause diminishing values? to clarify it's an integer variable as opposed to a units actual level. so wouldn't that mean it could only increase? 1 = 1, 2=2,...15=15, etc?
 
Last edited:
Level 14
Joined
Jun 27, 2008
Messages
1,325
So you want some kind of metric to measure how strong a unit is?

Without knowing your map or how your values look like its simply impossible to give a useful answer to that. Is 10000 Hp much in your map? Is lvl 8 close to the maximum level or is the maximum level 9000? Is 250 hp a lot for level 15? Etc..

Give us some examples, like:

1. A hero with 1000 hp, 600 mana and level 20 should receive the same value as a hero with 1400 hp, 750 mana and level 16.
2. A hero with 1000 hp, 700 mana, level 10 should receive twice the value as a hero with 600 hp, 400 mana, lvl 5.

With some of these examples its rather easy to find a spline or polynomial to interpolate these values. http://en.wikipedia.org/wiki/Interpolation

Also what does this mean:
. I want to be able to derive a value from these attributes combined that will increase in an exponential manner.
How shall they increase in an exponential manner? Exponential in every argument (hp, mana, level)? Or exponential in the sum of the arguments? etc... Please provide further specification or write down a formula.
 
Level 6
Joined
Jan 8, 2009
Messages
140
So you want some kind of metric to measure how strong a unit is?

Without knowing your map or how your values look like its simply impossible to give a useful answer to that. Is 10000 Hp much in your map? Is lvl 8 close to the maximum level or is the maximum level 9000? Is 250 hp a lot for level 15? Etc..

Give us some examples, like:

1. A hero with 1000 hp, 600 mana and level 20 should receive the same value as a hero with 1400 hp, 750 mana and level 16.
2. A hero with 1000 hp, 700 mana, level 10 should receive twice the value as a hero with 600 hp, 400 mana, lvl 5.

With some of these examples its rather easy to find a spline or polynomial to interpolate these values. http://en.wikipedia.org/wiki/Interpolation

Also what does this mean:

How shall they increase in an exponential manner? Exponential in every argument (hp, mana, level)? Or exponential in the sum of the arguments? etc... Please provide further specification or write down a formula.

Sorry i'm not great at maths or wording maths questions.

I'd ideally like health to weigh higher than mana in the end result, but level is the most influential on the end result. max level is 25, health and mana I haven't really sorted out yet but i'd say neither would exceed 5000.

There should be a small difference between 2 and 3, but large distance between 24-25 for example.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
I have 3 values and want to make a fourth value based on the other three. the three are max mana, max hp and level. I want to be able to derive a value from these attributes combined that will increase in an exponential manner.

Simplest formula that matches your requirements...
e ^ (k + a * maxmana + b * maxhealth + c * level)
e = natural constant (can be any constant you like and still work as long as it is >1 but natural constant is the most simple and implicit for exponentials).
a, b, c = scaling factors that are used to adjust how much each is worth in comparison to each other. The larger they are, the steeper the exponential will be as a result of that attribute.
k = exponential offset. It determines where on the exponential curve to start and may be useful at low values to ensure usefulness or if only available at high levels could be used to offset back to prevent stupidly large values..

This will increase in fully exponential manner. Every point of health, mana and level will be interchangeable when normalized to produce the same result so that stacking one is no better than the other.

To determine the constants used, first consider the amount of damage you want it to do end game. This is determined by your overall game balance as represents the approximate maximum damage you can except the move to do. Using a e you can do a ln (log to base e) of that value to get the total amount that the exponential can add up to. From this you can determine constants for the end game values of the hero required to create this value.

You will probably want health and mana multipliers to be very small. Level can then be made to dominate over them and determine the bulk of the exponential power. For example, if the total end mana and health product sum is about 0.4, this will result in 50% more damage over level alone (if e is used, different for different based exponentials).

Do be careful for mini-maxers as the formula is exponential. If they can raise the mana and health product sum to 2, 3 etc you may find yourself dealing considerably more damage than from level alone, to the point that it destroys everything in 1 shot. To solve this you could degrade the constants a and b by dividing by level so that health and mana become less valuable as level increases.
 
Status
Not open for further replies.
Top