Use unsynced RNG for Monte Carlo combat simulation
We don't exactly want combat simulation to cause OOS.
This commit is contained in:
parent
0c137c79cf
commit
2452007c15
1 changed files with 8 additions and 6 deletions
|
@ -1494,22 +1494,24 @@ monte_carlo_combat_matrix::monte_carlo_combat_matrix(unsigned int a_max_hp,
|
|||
|
||||
void monte_carlo_combat_matrix::simulate()
|
||||
{
|
||||
randomness::rng& rng = randomness::rng::default_instance();
|
||||
|
||||
for(unsigned int i = 0u; i < NUM_ITERATIONS; ++i) {
|
||||
bool a_hit = false;
|
||||
bool b_hit = false;
|
||||
bool a_slowed = randomness::generator->get_random_bool(a_initially_slowed_chance_);
|
||||
bool b_slowed = randomness::generator->get_random_bool(b_initially_slowed_chance_);
|
||||
bool a_slowed = rng.get_random_bool(a_initially_slowed_chance_);
|
||||
bool b_slowed = rng.get_random_bool(b_initially_slowed_chance_);
|
||||
const std::vector<double>& a_initial = a_slowed ? a_initial_slowed_ : a_initial_;
|
||||
const std::vector<double>& b_initial = b_slowed ? b_initial_slowed_ : b_initial_;
|
||||
unsigned int a_hp = randomness::generator->get_random_element(a_initial.begin(), a_initial.end());
|
||||
unsigned int b_hp = randomness::generator->get_random_element(b_initial.begin(), b_initial.end());
|
||||
unsigned int a_hp = rng.get_random_element(a_initial.begin(), a_initial.end());
|
||||
unsigned int b_hp = rng.get_random_element(b_initial.begin(), b_initial.end());
|
||||
unsigned int a_strikes = calc_blows_a(a_hp);
|
||||
unsigned int b_strikes = calc_blows_b(b_hp);
|
||||
|
||||
for(unsigned int j = 0u; j < rounds_ && a_hp > 0u && b_hp > 0u; ++j) {
|
||||
for(unsigned int k = 0u; k < std::max(a_strikes, b_strikes); ++k) {
|
||||
if(k < a_strikes) {
|
||||
if(randomness::generator->get_random_bool(a_hit_chance_)) {
|
||||
if(rng.get_random_bool(a_hit_chance_)) {
|
||||
// A hits B
|
||||
unsigned int damage = a_slowed ? a_slow_damage_ : a_damage_;
|
||||
damage = std::min(damage, b_hp);
|
||||
|
@ -1529,7 +1531,7 @@ void monte_carlo_combat_matrix::simulate()
|
|||
}
|
||||
|
||||
if(k < b_strikes) {
|
||||
if(randomness::generator->get_random_bool(b_hit_chance_)) {
|
||||
if(rng.get_random_bool(b_hit_chance_)) {
|
||||
// B hits A
|
||||
unsigned int damage = b_slowed ? b_slow_damage_ : b_damage_;
|
||||
damage = std::min(damage, a_hp);
|
||||
|
|
Loading…
Add table
Reference in a new issue