summaryrefslogtreecommitdiff
path: root/dungeon
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-10-23 15:01:39 -0400
committerFreya Murphy <freya@freyacat.org>2025-10-23 15:01:39 -0400
commit3dd78e2b8abc34c52e41786454f002568cec67ed (patch)
treef3e893c83927dc3d50970522ae469e41b376dd30 /dungeon
parentdungon: use EnumIter from strum to add values methods to enums (diff)
downloadDungeonCrawl-3dd78e2b8abc34c52e41786454f002568cec67ed.tar.gz
DungeonCrawl-3dd78e2b8abc34c52e41786454f002568cec67ed.tar.bz2
DungeonCrawl-3dd78e2b8abc34c52e41786454f002568cec67ed.zip
dungon: supress wfc clippy warnings (for now)
Diffstat (limited to 'dungeon')
-rw-r--r--dungeon/src/wfc.rs32
1 files changed, 17 insertions, 15 deletions
diff --git a/dungeon/src/wfc.rs b/dungeon/src/wfc.rs
index 5968000..0309546 100644
--- a/dungeon/src/wfc.rs
+++ b/dungeon/src/wfc.rs
@@ -5,18 +5,18 @@ use crate::map::Tile;
use crate::pos::Pos;
/// The `State` struct represents each possible state of a tile in the WFC algorithm.
-pub(crate) struct State {
+struct State {
/// Position of the tile
+ #[expect(dead_code)]
pos: Pos,
/// Possible tiles for this state
possible_tiles: Vec<Tile>,
/// Entropy of the state
entropy: f32,
}
-
impl State {
/// Creates a new State instance
- pub fn new(pos: Pos, possible_tiles: Vec<Tile>) -> Self {
+ fn new(pos: Pos, possible_tiles: Vec<Tile>) -> Self {
let entropy = 0.0;
Self {
pos,
@@ -26,33 +26,36 @@ impl State {
}
/// Updates the possible tiles and recalculates entropy
- pub fn update_possible_tiles(&mut self, possible_tiles: Vec<Tile>) {
+ #[expect(dead_code)]
+ fn update_possible_tiles(&mut self, possible_tiles: Vec<Tile>) {
self.possible_tiles = possible_tiles;
self.entropy = self.entropy();
}
/// Calculates the entropy of the state
/// TODO: Implement shannon entropy calculation
- pub fn entropy(&self) -> f32 {
+ fn entropy(&self) -> f32 {
self.possible_tiles.len() as f32
}
}
/// The `Wfc` struct encapsulates the Wave Function Collapse algorithm.
-pub struct Wfc {
+pub(crate) struct Wfc {
/// The seed used for randomness in the algorithm
+ #[expect(dead_code)]
seed: u64,
/// The size of the map to generate
+ #[expect(dead_code)]
mapsize: u16,
/// The current state of the WFC algorithm (smart pointer for interior mutability)
states: Vec<std::cell::RefCell<State>>,
/// The random number generator
+ #[expect(dead_code)]
rng: rand::rngs::StdRng,
}
-
impl Wfc {
/// Creates a new Wfc instance with the given seed and map size
- pub fn new(seed: u64, mapsize: u16) -> Self {
+ pub(crate) fn new(seed: u64, mapsize: u16) -> Self {
let rng = rand::SeedableRng::seed_from_u64(seed);
Self {
seed,
@@ -63,18 +66,17 @@ impl Wfc {
}
/// Initializes the states vector with default states
- pub fn initialize_states(&mut self) {
-
+ pub(crate) fn initialize_states(&mut self) {
for pos in Pos::values() {
- let possible_tiles = Tile::all_tiles();
- let state = State::new(pos, possible_tiles);
- self.states.push(std::cell::RefCell::new(state));
-
+ let possible_tiles = Tile::values().collect();
+ let state = State::new(pos, possible_tiles);
+ self.states.push(std::cell::RefCell::new(state));
}
}
/// Runs the Wave Function Collapse algorithm to generate the map
- pub fn run(&mut self) {
+ #[expect(clippy::unused_self)]
+ pub(crate) fn run(&mut self) {
// ----- Step 1: Read in input sample and define constraints -----
// TODO: add support for sample image input