1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Per-preset app-runtime defaults (third declarative seam). Resolved by
//! `ProfileOverrides::resolve_app` as the fallback between explicit override and
//! the global `AppRuntimeConfig::default()`.
use crate::simulation::config::Preset;
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct PresetAppDefaults {
pub auto_reset: bool,
/// Entropy-collapse threshold fallback when no CLI `--collapse-threshold` is
/// given. `0.0` disables the entropy detector (entropy is always `>= 0`, so
/// `entropy < 0.0` never fires), leaving only the stagnation detector.
pub entropy_threshold: f32,
}
impl Default for PresetAppDefaults {
fn default() -> Self {
Self {
auto_reset: crate::config_defaults::auto_reset::DEFAULT_AUTO_RESET,
entropy_threshold: crate::config_defaults::auto_reset::DEFAULT_ENTROPY_THRESHOLD,
}
}
}
impl From<Preset> for PresetAppDefaults {
fn from(preset: Preset) -> Self {
match preset {
// Constellation and Trademark hold their figure indefinitely via the
// per-frame template re-stamp, so they must NOT auto-reset — a reset
// would drop the held figure. Entropy threshold is moot while
// auto_reset is false; 0.0 keeps the detector off explicitly.
Preset::Constellation | Preset::Trademark => Self {
auto_reset: false,
entropy_threshold: 0.0,
},
_ => Self::default(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_mirrors_global() {
assert_eq!(
PresetAppDefaults::default().auto_reset,
crate::config_defaults::auto_reset::DEFAULT_AUTO_RESET
);
}
#[test]
fn constellation_opts_out_of_auto_reset() {
// Constellation holds its figure via template re-stamp — must NOT auto-reset.
assert!(!PresetAppDefaults::from(Preset::Constellation).auto_reset);
assert_eq!(
PresetAppDefaults::from(Preset::Network).auto_reset,
crate::config_defaults::auto_reset::DEFAULT_AUTO_RESET
);
}
#[test]
fn constellation_disables_entropy_detector() {
// 0.0 turns the entropy detector off (entropy is always >= 0).
assert_eq!(
PresetAppDefaults::from(Preset::Constellation).entropy_threshold,
0.0
);
// Other presets keep the global default.
assert_eq!(
PresetAppDefaults::from(Preset::Network).entropy_threshold,
crate::config_defaults::auto_reset::DEFAULT_ENTROPY_THRESHOLD
);
}
}