mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-26 03:51:45 +00:00
randomize cell state
This commit is contained in:
parent
6e88f0f750
commit
511a837495
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,6 +54,8 @@ func initGrid(width, height int, parent ...[][]Cell) ([][]Cell, error) {
|
|||||||
// If specified, copy state from parent
|
// If specified, copy state from parent
|
||||||
if exists {
|
if exists {
|
||||||
cells[i][j].live = parent[0][i][j].live
|
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