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
|
||||
.iter()
|
||||
.filter(|offset| {
|
||||
let neighbor = ((row as i64) + offset.0, (column as i64) + offset.1);
|
||||
let i = neighbor.0;
|
||||
let j = neighbor.1;
|
||||
i >= 0
|
||||
&& j >= 0
|
||||
&& (i as usize) < HEIGHT
|
||||
&& (j as usize) < WIDTH
|
||||
&& self[i as usize][j as usize]
|
||||
let height = (row as i64) + offset.0;
|
||||
let width = (column as i64) + offset.1;
|
||||
height >= 0
|
||||
&& width >= 0
|
||||
&& (height as usize) < HEIGHT
|
||||
&& (width as usize) < WIDTH
|
||||
&& self[height as usize][width as usize]
|
||||
})
|
||||
.count();
|
||||
future[row][column] = neighbors == 3 || *alive && neighbors == 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue