mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-25 11:31:46 +00:00
randomize cell state
This commit is contained in:
parent
6e88f0f750
commit
511a837495
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -53,6 +54,8 @@ func initGrid(width, height int, parent ...[][]Cell) ([][]Cell, error) {
|
||||
// If specified, copy state from parent
|
||||
if exists {
|
||||
cells[i][j].live = parent[0][i][j].live
|
||||
} else {
|
||||
cells[i][j].live = rand.Intn(2) == 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user