engine: Control experimental PRNG option via game classification
This removes the use_prng Advanced Preferences option and replaces it with a new possible value for randomness in the game classification class, "biased". It also changes the enumeration label for it in the GUI2 campaign dialog. It also makes it so the synced RNG is automatically used with this option as well as the existing deterministic randomness option ("save random seed").
This commit is contained in:
parent
ac53f93004
commit
4b5eabdfb0
7 changed files with 19 additions and 20 deletions
|
@ -167,15 +167,5 @@
|
|||
default=no
|
||||
[/advanced_preference]
|
||||
|
||||
[advanced_preference]
|
||||
field=use_prng
|
||||
name= _ "Use experimental PRNG combat"
|
||||
description= _ "Enables more determinstic chance-to-hit calculations. This is an experimental feature designed to bring the observed hit/miss rate more in line with the displayed percentages.
|
||||
|
||||
Note: this option only affects singleplayer, and the ‘Save random seed’ option must also be enabled when creating a game for this to work."
|
||||
type=boolean
|
||||
default=no
|
||||
[/advanced_preference]
|
||||
|
||||
#ifdef __UNUSED__
|
||||
#endif
|
||||
|
|
|
@ -323,10 +323,10 @@
|
|||
label = _ "Predictable RNG"
|
||||
details = "<span color='#777'>" + _ "Combat outcomes remain constant when reloading" + "</span>"
|
||||
[/option]
|
||||
#[option]
|
||||
# label = _ "Biased RNG"
|
||||
# details = "<span color='#777'>" + _ "Combat outcomes are more in line with displayed probabilities and unaffected by reloading" + "</span>"
|
||||
#[/option]
|
||||
[option]
|
||||
label = _ "Biased RNG (experimental)"
|
||||
details = "<span color='#777'>" + _ "Combat outcomes are more in line with displayed probabilities and unaffected by reloading" + "</span>"
|
||||
[/option]
|
||||
[/menu_button]
|
||||
[/column]
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "ai/lua/aspect_advancements.hpp"
|
||||
#include "formula/callable_objects.hpp"
|
||||
#include "formula/formula.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "game_data.hpp"
|
||||
#include "game_events/pump.hpp"
|
||||
|
@ -861,7 +862,7 @@ attack::attack(const map_location& attacker,
|
|||
, OOS_error_(false)
|
||||
|
||||
//new experimental prng mode.
|
||||
, use_prng_(preferences::get("use_prng") == "yes" && randomness::generator->is_networked() == false)
|
||||
, use_prng_(resources::classification->random_mode == "biased" && randomness::generator->is_networked() == false)
|
||||
{
|
||||
if(use_prng_) {
|
||||
std::cerr << "Using experimental PRNG for combat\n";
|
||||
|
|
|
@ -61,8 +61,16 @@ bool select_campaign(saved_game& state, jump_to_campaign_info jump_to_campaign)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(dlg.get_rng_mode() != gui2::dialogs::campaign_selection::RNG_DEFAULT) {
|
||||
random_mode = "deterministic";
|
||||
switch(dlg.get_rng_mode()) {
|
||||
case gui2::dialogs::campaign_selection::RNG_DEFAULT:
|
||||
random_mode = "";
|
||||
break;
|
||||
case gui2::dialogs::campaign_selection::RNG_SAVE_SEED:
|
||||
random_mode = "deterministic";
|
||||
break;
|
||||
case gui2::dialogs::campaign_selection::RNG_BIASED:
|
||||
random_mode = "biased";
|
||||
break;
|
||||
}
|
||||
|
||||
difficulty = dlg.get_difficulty();
|
||||
|
|
|
@ -465,7 +465,7 @@ void campaign_selection::post_show(window& window)
|
|||
}
|
||||
|
||||
|
||||
rng_mode_ = RNG_MODE(utils::clamp<unsigned>(find_widget<menu_button>(&window, "rng_menu", false).get_value(), RNG_DEFAULT, RNG_USE_PRNG));
|
||||
rng_mode_ = RNG_MODE(utils::clamp<unsigned>(find_widget<menu_button>(&window, "rng_menu", false).get_value(), RNG_DEFAULT, RNG_BIASED));
|
||||
|
||||
preferences::set_modifications(engine_.active_mods(), false);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
{
|
||||
RNG_DEFAULT,
|
||||
RNG_SAVE_SEED,
|
||||
RNG_USE_PRNG,
|
||||
RNG_BIASED,
|
||||
};
|
||||
|
||||
explicit campaign_selection(ng::create_engine& eng)
|
||||
|
|
|
@ -233,7 +233,7 @@ void synced_context::send_user_choice()
|
|||
std::shared_ptr<randomness::rng> synced_context::get_rng_for_action()
|
||||
{
|
||||
const std::string& mode = resources::classification->random_mode;
|
||||
if(mode == "deterministic") {
|
||||
if(mode == "deterministic" || mode == "biased") {
|
||||
return std::make_shared<randomness::rng_deterministic>(resources::gamedata->rng());
|
||||
} else {
|
||||
return std::make_shared<randomness::synced_rng>(generate_random_seed);
|
||||
|
|
Loading…
Add table
Reference in a new issue