mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-09-11 07:39:42 +00:00
optionally reuse old values
This commit is contained in:
parent
c9005a9150
commit
ef52dcfd7d
|
@ -9,15 +9,20 @@ pub struct Cell {
|
|||
pub state: u32,
|
||||
}
|
||||
|
||||
pub fn init_grid() -> Vec<Vec<Cell>> {
|
||||
pub fn init_grid(option: Option<&Vec<Vec<Cell>>>) -> Vec<Vec<Cell>> {
|
||||
let mut grid: Vec<Vec<Cell>> = Vec::new();
|
||||
for j in 0..HEIGHT {
|
||||
let mut row: Vec<Cell> = Vec::new();
|
||||
for i in 0..WIDTH {
|
||||
let mut value = rand::random::<u32>() % Q;
|
||||
if let Some(g) = option {
|
||||
value = g[j as usize][i as usize].state;
|
||||
}
|
||||
|
||||
row.push(Cell {
|
||||
x: i,
|
||||
y: j,
|
||||
state: 0,
|
||||
state: value,
|
||||
});
|
||||
}
|
||||
grid.push(row);
|
||||
|
|
Loading…
Reference in New Issue
Block a user