randomize cell state

This commit is contained in:
Baipyrus 2024-04-14 22:01:42 +02:00
parent 6e88f0f750
commit 511a837495

View File

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