Shannon Entropy
Turns out Shannon entropy is a really neat quantity (which I did study in college but forgot everything about). I essentially copy-pasted an implementation of a special case of Shannon entropy calculation, since I need that to ensure that the distrubution of all the tiles remain in the final world output is similar to the tiles in the source / sample image in my Wave Function Collapse Algorithm.
I was hoping that I would be done by this point in my holidays, but that haven't been the case. :-(
I couldn't figure out a proper test case for today and it's already 2300, so I just made sure the entropy is positive.
fn calculate_entropy() {
let string_rep =
"^~~^~\
BB~BB\
BT~BT\
^~~^~\
BB~BB\
";
let dim = 5;
let tile_dim = 3;
let world_sample = WorldSample::from_str(string_rep, dim);
let tile_data = world_sample.create_tiles(tile_dim);
let core_cell = CoreCell::from_tiles(&tile_data);
let entropy_of_cell = core_cell.entropy(&tile_data);
assert_eq!(entropy_of_cell > 0.0, true);
}
At this point the program is a large sudoku solver I suppose.
27-12-2023