Square tile weights for better control over probabilities
authorunC0Rr
Thu, 30 Jan 2025 13:59:31 +0100
changeset 16075 2c2b094e6bbe
parent 16074 fff7c8e36f7b
child 16076 8c90c8751b90
Square tile weights for better control over probabilities
rust/landgen/src/wavefront_collapse/generator.rs
rust/landgen/src/wavefront_collapse/wavefront_collapse.rs
--- a/rust/landgen/src/wavefront_collapse/generator.rs	Tue Jan 28 15:57:05 2025 +0100
+++ b/rust/landgen/src/wavefront_collapse/generator.rs	Thu Jan 30 13:59:31 2025 +0100
@@ -120,7 +120,6 @@
             a => {
                 for line in bytes.chunks_exact(info.line_size) {
                     for value in line.chunks_exact(a) {
-                        print!("{:?},", value);
                         *tiles_image_pixels
                             .next()
                             .expect("vec2d size matching image dimensions") =
--- a/rust/landgen/src/wavefront_collapse/wavefront_collapse.rs	Tue Jan 28 15:57:05 2025 +0100
+++ b/rust/landgen/src/wavefront_collapse/wavefront_collapse.rs	Thu Jan 30 13:59:31 2025 +0100
@@ -160,7 +160,7 @@
                     let entropy = possibilities.len();
                     if entropy > 0 {
                         if entropy <= tiles_to_collapse.0 {
-                            let weights = possibilities.iter().map(|(weight, _)| *weight);
+                            let weights = possibilities.iter().map(|(weight, _)| weight.pow(2));
                             let distribution = WeightedIndex::new(weights).unwrap();
 
                             let entry =