From 511a83749533cc7d59700aba1b43a260292f14e1 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sun, 14 Apr 2024 22:01:42 +0200 Subject: [PATCH] randomize cell state --- conway.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conway.go b/conway.go index 9429b85..f1ce95c 100644 --- a/conway.go +++ b/conway.go @@ -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 } } }