Skip to content

Commit dcf1e2f

Browse files
committed
use seeded random generator in shufflecells function instead of the unseeded (since go1.20) global one
1 parent 5d7dc83 commit dcf1e2f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

engine/ext_make3dgrains.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func newTesselation3d(grainsize float64, nRegion int, seed int64, startRegion in
5757

5858
// Permutes the slice of cell locations. I don't understand why this needs to be done if we're choosing
5959
// random (Intn()) cells out of the slice of cell locations, but hey, it seems to do the trick.
60-
func shuffleCells(src []cellLocs) []cellLocs {
60+
func (t *tesselation3d) shuffleCells(src []cellLocs) []cellLocs {
6161
dest := make([]cellLocs, len(src))
62-
perm := rand.Perm(len(src))
62+
perm := t.rnd.Perm(len(src))
6363
for i, v := range perm {
6464
dest[v] = src[i]
6565
}
@@ -69,7 +69,7 @@ func shuffleCells(src []cellLocs) []cellLocs {
6969
func (t *tesselation3d) makeRandomCenters() {
7070
//Make a list of all the cells in the shape.
7171
cells := t.tabulateCells()
72-
cells = shuffleCells(cells)
72+
cells = t.shuffleCells(cells)
7373

7474
//Choose number of grains to make. Assume volume of grain is given by (4/3)*pi*r^3
7575
shapeVolume := cellVolume() * float64(len(cells))

0 commit comments

Comments
 (0)