use DIR_POS for box testing
This commit is contained in:
parent
412072abda
commit
41af614d74
|
@ -189,6 +189,8 @@ struct State {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
|
const DIR_POS: &'static [Pos] = &[Pos(0, -1), Pos(0, 1), Pos(-1, 0), Pos(1, 0)];
|
||||||
|
|
||||||
fn new(lvl: Level) -> Self {
|
fn new(lvl: Level) -> Self {
|
||||||
State { lvl }
|
State { lvl }
|
||||||
}
|
}
|
||||||
|
@ -250,10 +252,9 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_box(&self, pos: Pos, bt: bool) -> bool {
|
fn test_box(&self, pos: Pos, bt: bool) -> bool {
|
||||||
let dir: &[Pos] = &[Pos(0, -1), Pos(0, 1), Pos(-1, 0), Pos(1, 0)];
|
|
||||||
let mut mbc = 0;
|
let mut mbc = 0;
|
||||||
|
|
||||||
for i in dir {
|
for i in Self::DIR_POS {
|
||||||
match self.lvl[pos + *i] {
|
match self.lvl[pos + *i] {
|
||||||
Cell::Goal(false) | Cell::None => {
|
Cell::Goal(false) | Cell::None => {
|
||||||
let dpos = pos - *i;
|
let dpos = pos - *i;
|
||||||
|
|
Loading…
Reference in New Issue