Skip to content

Commit b307843

Browse files
committed
Change to PCG random number generator algorithm
See http://www.pcg-random.org/ for benefits of PCG over xorshift Updates #236 #183
1 parent 6c32fce commit b307843

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ flate2 = { version = "1.0.13", features = ["rust_backend"], default-features = f
3232
zip = { version = "0.5.3", features = ["deflate"], default-features = false }
3333
image = "0.22.3"
3434
rand = "0.7.2"
35-
rand_xorshift = "0.2.0"
35+
rand_pcg = "0.2.1"
3636
hex = "0.4.0"
3737
base64 = "0.11.0"
3838
log = { version = "0.4.8", features = ["std"] }

src/chunk_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::model;
1010
use crate::types::bit::Set;
1111
use crate::shared::Direction;
1212
use rand::{self, SeedableRng, Rng};
13-
use rand_xorshift;
13+
use rand_pcg;
1414

1515
const NUM_WORKERS: usize = 8;
1616

@@ -122,7 +122,7 @@ fn build_func(id: usize, models: Arc<RwLock<model::Factory>>, work_recv: mpsc::R
122122
Err(_) => return,
123123
};
124124

125-
let mut rng = rand_xorshift::XorShiftRng::from_seed([
125+
let mut rng = rand_pcg::Pcg32::from_seed([
126126
((position.0 as u32) & 0xff) as u8,
127127
(((position.0 as u32) >> 8) & 0xff) as u8,
128128
(((position.0 as u32) >> 16) & 0xff) as u8,

src/ui/logo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::render;
66
use crate::resources;
77
use std::time::{SystemTime, UNIX_EPOCH};
88
use rand::{self, seq::SliceRandom};
9-
use rand_xorshift;
9+
use rand_pcg;
1010

1111
pub struct Logo {
1212
_shadow: ui::BatchRef,
@@ -101,7 +101,7 @@ impl Logo {
101101
text_strings.push(line.to_owned().replace("\r", ""));
102102
}
103103
}
104-
let mut r: rand_xorshift::XorShiftRng = rand::SeedableRng::from_seed([45, 0, 0, 0, 64, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0]);
104+
let mut r: rand_pcg::Pcg32 = rand::SeedableRng::from_seed([45, 0, 0, 0, 64, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0]);
105105
text_strings.shuffle(&mut r);
106106
}
107107

0 commit comments

Comments
 (0)