Skip to content

Commit

Permalink
Make this the default; better docs; some trace-logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
RundownRhino committed Dec 13, 2023
1 parent 8311440 commit c9d31b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,19 @@ pub fn remove_too_rare(results_by_dim: &mut [(BlockFrequencies, RegionVersion)],
// metric would change for the same world between versions.
let world_height = 255f64;
for (freqs, _) in results_by_dim.iter_mut() {
freqs.frequencies.retain(|_, v: &mut HashMap<isize, f64>| {
freqs.frequencies.retain(|k, v: &mut HashMap<isize, f64>| {
let normalized_frequency = v.values().sum::<f64>() / world_height;
normalized_frequency >= cutoff
if normalized_frequency >= cutoff {
true
} else {
trace!(
"Dropping record ({}, {}) with normalized frequency {:.2e}.",
&freqs.dimension,
k,
normalized_frequency
);
false
}
});
}
}
18 changes: 10 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ struct Args {
/// set to zero, will be chosen automatically by rayon.
#[arg(short, long, default_value_t = 0)]
threads: usize,
/// If set, only blocks with a normalized frequency (sum of frequencies by
/// level divided by 255 (even in 1.18+ worlds)) above this parameter
/// will be exported. For example, a value of 0.01 means retain blocks
/// more common that 1 in 100 (which means ~655 such blocks per
/// 255-height chunk). A good value for this is 1e-7, which is about 26
/// blocks pre 4096 chunks. Some comparisons: minecraft:emerald_ore is
/// about 3e-6, minecraft:ancient_debris is about 2e-5.
#[arg(short, long, required = false)]
/// If not none, only blocks with a normalized frequency above this value
/// will be exported. Normalized frequency is the sum of frequencies by
/// level divided by 255 (even in 1.18+ worlds which are higher than that).
/// For example, a value of 0.01 means retain blocks more common that 1
/// in 100 (which is ~655 such blocks per 255-height chunk). The default
/// value is 1e-7, which is about 26 blocks pre 4096 chunks.
/// Some comparisons: minecraft:emerald_ore is ~3e-6,
/// minecraft:deepslate_emerald_ore (1.18) is ~2e-7,
/// minecraft:ancient_debris is ~2e-5.
#[arg(short, long, required = false, default_value = "1e-7")]
only_blocks_above: Option<f64>,
}

Expand Down

0 comments on commit c9d31b2

Please sign in to comment.