Skip to content

Commit

Permalink
Put the Monte Carlo mode behind an advanced preference and update cha…
Browse files Browse the repository at this point in the history
…ngelog
  • Loading branch information
jyrkive committed Jul 21, 2016
1 parent d83e017 commit 6766e05
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
9 changes: 9 additions & 0 deletions changelog
Expand Up @@ -49,6 +49,15 @@ Version 1.13.4+dev:
loggers activated in the gui print just like loggers activated in the
command line (i.e. messages appear in the console)
* Fix bug #24762: Editor actions are out of sync after resizing.
* Performance:
* Added an advanced preference (Preferences -> Advanced ->
Allow damage calculation with Monte Carlo simulation) that, when enabled,
allows the damage calculation to operate by simulating a few thousand fights
instead of calculating exact probabilities of each outcome (when a heuristic
determines that it's probably faster). This method is inexact, but in very
complex battles (extremely high HP, drain, slow, berserk, etc.) it's
significantly faster than the default damage calculation method, and may be
necessary for acceptable performance.
* WML engine:
* Add color= attribute to [message].
* Add [else], search_recall_list=, auto_recall= to [role]
Expand Down
8 changes: 8 additions & 0 deletions data/advanced_preferences.cfg
Expand Up @@ -188,6 +188,14 @@
type=custom
[/advanced_preference]

[advanced_preference]
field=damage_prediction_allow_monte_carlo_simulation
name= _ "Allow damage calculation with Monte Carlo simulation"
description= _ "Allow the damage calculation window to simulate fights instead of using exact probability calculations"
type=boolean
default=no
[/advanced_preference]

#ifdef __UNUSED__
[advanced_preference]
field=joystick_support_enabled
Expand Down
10 changes: 10 additions & 0 deletions players_changelog
Expand Up @@ -32,6 +32,16 @@ Version 1.13.4+dev:
* Added "Registered users only" checkbox to multiplayer configuration dialog which
when checked, only allows registered users to join the game

* Performance:
* Added an advanced preference (Preferences -> Advanced ->
Allow damage calculation with Monte Carlo simulation) that, when enabled,
allows the damage calculation to operate by simulating a few thousand fights
instead of calculating exact probabilities of each outcome (when a heuristic
determines that it's probably faster). This method is inexact, but in very
complex battles (extremely high HP, drain, slow, berserk, etc.) it's
significantly faster than the default damage calculation method, and may be
necessary for acceptable performance.

Version 1.13.4:
* Language and i18n:
* Updated translations: British English, Russian.
Expand Down
4 changes: 3 additions & 1 deletion src/attack_prediction.cpp
Expand Up @@ -40,6 +40,7 @@

#include "actions/attack.hpp"
#include "game_config.hpp"
#include "preferences.hpp"
#include "random_new.hpp"
#include <array>
#include <cmath>
Expand Down Expand Up @@ -1986,7 +1987,8 @@ void combatant::fight(combatant &opp, bool levelup_considered)
const std::vector<combat_slice> opp_split = split_summary(opp.u_, opp.summary);

if (fight_complexity(split.size(), opp_split.size(), u_, opp.u_) >
MONTE_CARLO_SIMULATION_THRESHOLD)
MONTE_CARLO_SIMULATION_THRESHOLD &&
preferences::damage_prediction_allow_monte_carlo_simulation())
{
// A very complex fight. Use Monte Carlo simulation instead of exact
// probability calculations.
Expand Down
10 changes: 10 additions & 0 deletions src/preferences.cpp
Expand Up @@ -1041,5 +1041,15 @@ void set_disable_loadingscreen_animation(bool value)
set("disable_loadingscreen_animation", value);
}

bool damage_prediction_allow_monte_carlo_simulation()
{
return get("damage_prediction_allow_monte_carlo_simulation", false);
}

void set_damage_prediction_allow_monte_carlo_simulation(bool value)
{
set("damage_prediction_allow_monte_carlo_simulation", value);
}

} // end namespace preferences

3 changes: 3 additions & 0 deletions src/preferences.hpp
Expand Up @@ -263,6 +263,9 @@ namespace preferences {
bool disable_loadingscreen_animation();
void set_disable_loadingscreen_animation(bool value);

bool damage_prediction_allow_monte_carlo_simulation();
void set_damage_prediction_allow_monte_carlo_simulation(bool value);

} // end namespace preferences

#endif

0 comments on commit 6766e05

Please sign in to comment.