Skip to content

Commit

Permalink
Adjust fight length distribution for target_error simulations
Browse files Browse the repository at this point in the history
Before, fight lengths of target_error simulations were skewed towards
the extremes (i.e., max_time +- vary_combat_length), instead of
approximating an uniform distribution like iteration-based sims do. This
commit changes target_error sims to use a randomly uniform variable in
the range of max_time +- vary_combat_length to approximate the behavior
iteration-based simulations have.

This also has the added benefit that in very high target_error values,
we now get proper variance of combat time.
  • Loading branch information
navv1234 committed Aug 17, 2018
1 parent 6dbc16c commit c2dfa28
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions engine/sim/sc_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,20 @@ double sim_t::iteration_time_adjust() const
if ( current_iteration == 0 )
return 1.0;

auto progress = work_queue -> progress();
return 1.0 + vary_combat_length * ( ( current_iteration % 2 ) ? 1 : -1 ) * progress.pct();
// Approximate uniform distribution for fight lengths through randomization when target error is
// used. Will generate more fair fight length distribution when reasonable (<0.5) target_error
// values are chosen, and removes issues with pathological cases where high values are used (high
// enough for analyze_error_interval to bound the number of iterations done, instead of the
// target_error).
if ( target_error != 0 )
{
return rng().range( 1.0 - vary_combat_length, 1.0 + vary_combat_length );
}
else
{
auto progress = work_queue -> progress();
return 1.0 + vary_combat_length * ( ( current_iteration % 2 ) ? 1 : -1 ) * progress.pct();
}
}

// sim_t::expected_max_time =================================================
Expand Down

0 comments on commit c2dfa28

Please sign in to comment.