Skip to content

Commit

Permalink
updates rand
Browse files Browse the repository at this point in the history
  • Loading branch information
coilysiren committed Nov 24, 2023
1 parent ca1fa90 commit b170b09
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 42 deletions.
58 changes: 18 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ path = "src/rust/lib.rs"
console_error_panic_hook = "^0.1"
specs = "^0.12"
specs-derive = "^0.2"
rand = "^0.5"
wasm-bindgen = "^0.2"
getrandom = { version = "^0.2", features = ["js", "wasm-bindgen"] }
rand = "^0.8"

[dev-dependencies]
cargo-watch = "^7"
Expand Down
3 changes: 2 additions & 1 deletion src/rust/galaxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ impl Galaxy {
pub fn seed(&self, additional: u16) -> Galaxy {
// add mass to the galaxy
let mut next = Vec::with_capacity((self.size as usize).pow(2));
let mut rng = rand::thread_rng();
for cell_index in 0..self.size.pow(2) {
let mass = self.cells[cell_index as usize].mass;
next.push(Cell {
mass: mass + rand::thread_rng().gen_range(0, additional + 1),
mass: mass + rng.gen_range(0..additional + 1),
..Default::default()
});
}
Expand Down

0 comments on commit b170b09

Please sign in to comment.