refactor
This commit is contained in:
parent
9b83a39018
commit
432191b718
1 changed files with 7 additions and 8 deletions
15
src/main.rs
15
src/main.rs
|
@ -71,14 +71,13 @@ impl Life {
|
||||||
let neighbors = OFFSETS
|
let neighbors = OFFSETS
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|offset| {
|
.filter(|offset| {
|
||||||
let neighbor = ((row as i64) + offset.0, (column as i64) + offset.1);
|
let height = (row as i64) + offset.0;
|
||||||
let i = neighbor.0;
|
let width = (column as i64) + offset.1;
|
||||||
let j = neighbor.1;
|
height >= 0
|
||||||
i >= 0
|
&& width >= 0
|
||||||
&& j >= 0
|
&& (height as usize) < HEIGHT
|
||||||
&& (i as usize) < HEIGHT
|
&& (width as usize) < WIDTH
|
||||||
&& (j as usize) < WIDTH
|
&& self[height as usize][width as usize]
|
||||||
&& self[i as usize][j as usize]
|
|
||||||
})
|
})
|
||||||
.count();
|
.count();
|
||||||
future[row][column] = neighbors == 3 || *alive && neighbors == 2;
|
future[row][column] = neighbors == 3 || *alive && neighbors == 2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue