diff --git a/README.md b/README.md index b838fc1..a6c54f9 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ options. Some of the more important are: -k, --keep-core-mods Prevent swapping of core mods. Only change the values of existing mods. + Specifying this option twice prevents downgrading mods from the original + values. -i, --income Optimize for runestone income instead of damage. This is much slower so it diff --git a/spire.cpp b/spire.cpp index b01a6e7..fde6227 100644 --- a/spire.cpp +++ b/spire.cpp @@ -78,6 +78,7 @@ Spire::Spire(int argc, char **argv): budget(0), core_budget(0), core_mutate(Core::ALL_MUTATIONS), + no_core_downgrade(false), income(false), towers(false), score_func(damage_score) @@ -99,7 +100,7 @@ Spire::Spire(int argc, char **argv): bool exact = false; std::string budget_str; std::string core_budget_str; - bool keep_core_mods = false; + unsigned keep_core_mods = 0; std::string tower_type; unsigned towers_seen = 0; @@ -219,7 +220,10 @@ Spire::Spire(int argc, char **argv): } if(keep_core_mods) + { core_mutate = Core::VALUES_ONLY; + no_core_downgrade = (keep_core_mods>=2); + } if(!n_pools_seen && heterogeneous) n_pools = 21; @@ -1078,7 +1082,16 @@ void Spire::Worker::main() Core core = mutated.get_core(); core.mutate(spire.core_mutate, 1+random()%5, random); core.update(); - if(core.cost<=spire.core_budget) + + bool ok = (core.cost<=spire.core_budget); + + if(ok && spire.no_core_downgrade) + { + for(unsigned j=0; (ok && j=mutated.get_core().get_mod(j)); + } + + if(ok) mutated.set_core(core); } diff --git a/spire.h b/spire.h index fce56bb..b621dca 100644 --- a/spire.h +++ b/spire.h @@ -72,6 +72,7 @@ class Spire Number budget; Number core_budget; Core::MutateMode core_mutate; + bool no_core_downgrade; bool income; bool towers; Pool::ScoreFunc *score_func;