如何添加随机“模糊”?到这个公式,以便随机性随着值的增加而减少?
我正在开发一款开放式策略游戏。我使用以下公式来计算伤害:
$rand = rand($a, $b) + $c;
$damage = $rand * sqrt(($d / 20) * $c));
$a
、$b
、$c
和 $d
是用户在游戏过程中可以修改的所有值,可以通过购买更好的物品($a
和 $b
)、投资该物品(< code>$c),或者投资他们的角色$d
。
我现在想做的是为方程的结果添加一点随机性。然而,由于游戏是开放式的:
- 随着时间的推移,静态值将变得不明显/可以忽略不计。
- 基于百分比的值会随着时间的推移而产生过多的噪音。
因此,我想添加一个随机值,该值一开始很小,随着输入的增加而增长,但收益递减。我确定我需要某种对数公式,但我不知道如何去做!
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:
- a static value would become unnoticeable/negligible over time.
- a percentage based value would allow for too much noise 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你计算你的原始伤害,因为 D 和 R 在 [-1,1] 中是随机的,那么你有很多选择。你不想要静态:
或百分比
之间的东西可能是
常数和线性之间的任何 D 函数都会给你一个不同的平衡。
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:
or percentage
Something in between might be
Any function of D between constant and linear will give you a different balance.