sim: use usize instead of i16 for garbage level min/max
This commit is contained in:
parent
68cb2cae58
commit
e64b11cefe
|
@ -8,7 +8,7 @@ pub struct Garbage<R: Rng> {
|
||||||
// current level of garbage on the matrix
|
// current level of garbage on the matrix
|
||||||
level: i16,
|
level: i16,
|
||||||
// min/max garbage to insert on the matrix
|
// min/max garbage to insert on the matrix
|
||||||
range: RangeInclusive<i16>,
|
range: RangeInclusive<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Rng> Garbage<R> {
|
impl<R: Rng> Garbage<R> {
|
||||||
|
@ -17,7 +17,7 @@ impl<R: Rng> Garbage<R> {
|
||||||
/// - `rng`: random number source
|
/// - `rng`: random number source
|
||||||
/// - `count`: total number of garbage rows to insert
|
/// - `count`: total number of garbage rows to insert
|
||||||
/// - `range`: min/max amount of garbage on the matrix at a given time
|
/// - `range`: min/max amount of garbage on the matrix at a given time
|
||||||
pub fn new(rng: R, count: usize, range: RangeInclusive<i16>) -> Self {
|
pub fn new(rng: R, count: usize, range: RangeInclusive<usize>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cheese: Cheese::new(rng).take(count),
|
cheese: Cheese::new(rng).take(count),
|
||||||
level: 0,
|
level: 0,
|
||||||
|
@ -47,7 +47,7 @@ impl<R: Rng> Garbage<R> {
|
||||||
} else {
|
} else {
|
||||||
*self.range.end()
|
*self.range.end()
|
||||||
};
|
};
|
||||||
let difference = (target as usize).saturating_sub(self.level as usize);
|
let difference = target.saturating_sub(self.level as usize);
|
||||||
|
|
||||||
(&mut self.cheese)
|
(&mut self.cheese)
|
||||||
.take(difference)
|
.take(difference)
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub struct Options {
|
||||||
/// Total number of garbage lines required to clear.
|
/// Total number of garbage lines required to clear.
|
||||||
pub goal: usize,
|
pub goal: usize,
|
||||||
/// Min/max number of garbage lines on the matrix at a given time.
|
/// Min/max number of garbage lines on the matrix at a given time.
|
||||||
pub garbage: RangeInclusive<i16>,
|
pub garbage: RangeInclusive<usize>,
|
||||||
/// Number of preview pieces.
|
/// Number of preview pieces.
|
||||||
pub previews: usize,
|
pub previews: usize,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue