This commit is contained in:
Tim Schubert 2024-12-28 02:47:45 +01:00
parent 9b83a39018
commit 432191b718
Signed by: dadada
SSH key fingerprint: SHA256:bFAjFH3hR8zRBaJjzQDjc3o4jqoq5EZ87l+KXEjxIz0

View file

@ -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;