pub(crate) struct XorShift32(u32);
impl XorShift32 {
pub(crate) fn new(seed: u32) -> Self {
Self(seed.max(1))
}
fn next(&mut self) -> u32 {
self.0 ^= self.0 << 13;
self.0 ^= self.0 >> 17;
self.0 ^= self.0 << 5;
self.0
}
pub(crate) fn below(&mut self, bound: usize) -> usize {
usize::try_from(self.next()).unwrap_or(0) % bound
}
pub(crate) fn text(&mut self, pieces: &[&str], max_pieces: usize) -> String {
let count = self.below(max_pieces + 1);
(0..count)
.map(|_| pieces[self.below(pieces.len())])
.collect()
}
}
pub(crate) const BOUNDARY_PIECES: &[&str] = &[
"a",
"Z",
"k",
"K",
"\u{212a}",
"\u{130}",
"i",
"I",
"\u{e9}",
"\u{c9}",
"\u{3a3}",
"\u{1f600}",
"\u{200b}",
"\u{feff}",
"\u{301}",
"0",
"9",
"_",
"-",
".",
":",
"=",
"\"",
"'",
",",
"[",
"]",
" ",
"\t",
"\n",
"*",
"x",
"X",
];