【发布时间】:2019-08-17 12:08:06
【问题描述】:
我正在尝试模拟野生口袋妖怪遭遇。如公式所述:
The rate of Pokémon encounter is determined from a simple mathematical formula:
1 in (187.5 / ( x )) per step.
Let x equal the a value which determines how rare the Pokémon is. The higher the encounter rate,
the more common the Pokémon is.
Encounter-rate Table
Encounter type Encounter rate
Very common 10
Common 8.5
Semi-rare 6.75
Rare 3.33
Very rare 1.25
我想在每次按下按钮后运行这个概率。如何用rand() 模拟这个?
【问题讨论】:
-
我可以说服您使用
std::discrete_distribution代替rand吗?randkinda sucks. -
@user4581301 确定!
-
遗憾的是,重新阅读时,
std::discrete_distribution并不是适合这项工作的工具。它非常适合加权遭遇,但这并不是您在这里所做的。如果是这样,代码将类似于:ideone.com/Vud9UC
标签: c++ visual-c++ random probability weighted