Skip to content

Commit

Permalink
use seeded random generator in shufflecells function instead of the u…
Browse files Browse the repository at this point in the history
…nseeded (since go1.20) global one
  • Loading branch information
JLeliaert committed Oct 3, 2024
1 parent 5d7dc83 commit dcf1e2f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions engine/ext_make3dgrains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand All @@ -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))
Expand Down

0 comments on commit dcf1e2f

Please sign in to comment.