diff --git a/Cargo.lock b/Cargo.lock index 675c88b..88f2d4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,15 +212,6 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - [[package]] name = "proc-macro2" version = "1.0.95" @@ -251,17 +242,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", "rand_core", ] @@ -647,23 +627,3 @@ checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags 2.9.1", ] - -[[package]] -name = "zerocopy" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/Cargo.toml b/Cargo.toml index 19116f9..f15ac74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ tracing-subscriber = {version = "0.3.17", features = ["env-filter"]} lazy_static = "1.5.0" sdl2 = { version = "0.38.0", features = ["image", "ttf"] } spin_sleep = "1.3.2" -rand = "0.9.2" +rand = { version = "0.9.2", default-features = false, features = ["small_rng", "os_rng"] } pathfinding = "4.14" once_cell = "1.21.3" thiserror = "1.0" diff --git a/src/game.rs b/src/game.rs index ff58457..838e47e 100644 --- a/src/game.rs +++ b/src/game.rs @@ -4,7 +4,9 @@ use std::ops::Not; use std::rc::Rc; use glam::UVec2; +use rand::rngs::SmallRng; use rand::seq::IteratorRandom; +use rand::SeedableRng; use sdl2::image::LoadTexture; use sdl2::keyboard::Keycode; use sdl2::render::{Texture, TextureCreator}; @@ -211,7 +213,7 @@ impl<'a> Game<'a> { { let mut map = self.map.borrow_mut(); let valid_positions = map.get_valid_playable_positions(); - let mut rng = rand::rng(); + let mut rng = SmallRng::from_os_rng(); // Randomize Pac-Man position if let Some(pos) = valid_positions.iter().choose(&mut rng) { diff --git a/src/ghost.rs b/src/ghost.rs index a3919c3..8cbb0b5 100644 --- a/src/ghost.rs +++ b/src/ghost.rs @@ -1,4 +1,6 @@ +use rand::rngs::SmallRng; use rand::Rng; +use rand::SeedableRng; use crate::animation::{AnimatedAtlasTexture, FrameDrawn}; use crate::constants::{MapTile, BOARD_WIDTH}; @@ -117,7 +119,7 @@ impl Ghost<'_> { /// Gets a random adjacent tile for frightened mode fn get_random_target(&self) -> IVec2 { - let mut rng = rand::rng(); + let mut rng = SmallRng::from_os_rng(); let mut possible_moves = Vec::new(); // Check all four directions diff --git a/src/map.rs b/src/map.rs index c637514..8593296 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,5 +1,7 @@ //! This module defines the game map and provides functions for interacting with it. +use rand::rngs::SmallRng; use rand::seq::IteratorRandom; +use rand::SeedableRng; use crate::constants::{MapTile, BOARD_OFFSET, CELL_SIZE}; use crate::constants::{BOARD_HEIGHT, BOARD_WIDTH}; @@ -120,7 +122,7 @@ impl Map { } } } - let mut rng = rand::rng(); + let mut rng = SmallRng::from_os_rng(); let &start = pellet_positions .iter() .choose(&mut rng)