开发者

How can I add random “fuzz” to this formula, so that the randomness diminishes as values increase?

I'm developing an open-ended strategy game. I am using the following formula to calculate damage:

$rand = rand($a, $b) + $c;
$damage = $rand * sqrt(($d / 20) * $c));

$a, $b, $c, and $d are all values that can be modified by the user over the course of play, either by buying a better item ($a and $b), investing in the item ($c), or investing in their character $d.

What I want to do now is add a bit of randomness to the outcome of the equation. However, because the game is open ended:

  1. a static value would become unnoticeable/negligible over time.
  2. a percentage based value would allow for too much n开发者_StackOverflow社区oise over time.

So, I want to add a random value that is small at first, grows with increased input, but has diminishing returns. I'm sure I need some kind of logarithmic formula, but I'm not sure how to go about it!


If you calculate your original damage as D and R is random in [-1,1], you have lots of options. You didn't want static:

D = D + 1 * constant * R

or percentage

D = D + D * constant * R.

Something in between might be

D = D + sqrt(D) * constant * R.

Any function of D between constant and linear will give you a different balance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜