Cheese uses u32 as internal state (for determinism reasons)
This commit is contained in:
parent
d61e6588c7
commit
05e6bc3e50
|
@ -1,4 +1,4 @@
|
|||
use mino::matrix::{Mat, MatBuf, COLUMNS};
|
||||
use mino::matrix::{Mat, MatBuf};
|
||||
use mino::srs::{Piece, PieceType};
|
||||
use rand::{Rng as _, SeedableRng as _};
|
||||
use std::collections::VecDeque;
|
||||
|
@ -225,28 +225,28 @@ impl Garbage {
|
|||
}
|
||||
}
|
||||
|
||||
fn garbage_row(col: i16) -> u16 {
|
||||
fn garbage_row(col: u32) -> u16 {
|
||||
!(1 << col)
|
||||
}
|
||||
|
||||
struct Cheese {
|
||||
rng: Rng,
|
||||
col: i16,
|
||||
col: u32,
|
||||
}
|
||||
|
||||
impl Cheese {
|
||||
fn new(mut rng: Rng) -> Self {
|
||||
let col = rng.gen_range(0..COLUMNS);
|
||||
let col = rng.gen_range(0..10);
|
||||
Self { rng, col }
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for Cheese {
|
||||
type Item = i16;
|
||||
type Item = u32;
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.col += self.rng.gen_range(1..COLUMNS);
|
||||
self.col %= COLUMNS;
|
||||
self.col += self.rng.gen_range(1..10);
|
||||
self.col %= 10;
|
||||
Some(self.col)
|
||||
}
|
||||
}
|
||||
|
@ -363,8 +363,8 @@ mod tests {
|
|||
prev = Some(x1);
|
||||
history.insert(x1);
|
||||
}
|
||||
assert_eq!(history.len(), COLUMNS as usize);
|
||||
for x in 0..COLUMNS {
|
||||
assert_eq!(history.len(), 10);
|
||||
for x in 0..10 {
|
||||
assert!(history.contains(&x));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue