From dcf1e2fda20c33d74e517626ff0ef8c41cbdcefc Mon Sep 17 00:00:00 2001 From: jleliaer Date: Thu, 3 Oct 2024 23:15:24 +0200 Subject: [PATCH] use seeded random generator in shufflecells function instead of the unseeded (since go1.20) global one --- engine/ext_make3dgrains.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/ext_make3dgrains.go b/engine/ext_make3dgrains.go index 77a8bc5be..b65745f4b 100644 --- a/engine/ext_make3dgrains.go +++ b/engine/ext_make3dgrains.go @@ -57,9 +57,9 @@ func newTesselation3d(grainsize float64, nRegion int, seed int64, startRegion in // Permutes the slice of cell locations. I don't understand why this needs to be done if we're choosing // random (Intn()) cells out of the slice of cell locations, but hey, it seems to do the trick. -func shuffleCells(src []cellLocs) []cellLocs { +func (t *tesselation3d) shuffleCells(src []cellLocs) []cellLocs { dest := make([]cellLocs, len(src)) - perm := rand.Perm(len(src)) + perm := t.rnd.Perm(len(src)) for i, v := range perm { dest[v] = src[i] } @@ -69,7 +69,7 @@ func shuffleCells(src []cellLocs) []cellLocs { func (t *tesselation3d) makeRandomCenters() { //Make a list of all the cells in the shape. cells := t.tabulateCells() - cells = shuffleCells(cells) + cells = t.shuffleCells(cells) //Choose number of grains to make. Assume volume of grain is given by (4/3)*pi*r^3 shapeVolume := cellVolume() * float64(len(cells))