Files
RPG_City_Maker_Reborn/seed.go
T

23 lines
604 B
Go
Raw Normal View History

2026-02-04 15:15:47 -06:00
package main
import "math/rand"
2026-02-05 17:50:55 -06:00
// SeedProvider is a simple struct that provides a stream of random seeds
// from a single initial seed. This ensures that the entire map generation
// process is deterministic if the same initial seed is used.
2026-02-04 15:15:47 -06:00
type SeedProvider struct {
rand *rand.Rand
}
2026-02-05 17:50:55 -06:00
// NewSeedProvider creates a new SeedProvider with the given initial seed.
2026-02-04 15:15:47 -06:00
func NewSeedProvider(seed int64) *SeedProvider {
return &SeedProvider{
rand: rand.New(rand.NewSource(seed)),
}
}
2026-02-05 17:50:55 -06:00
// Next returns the next random seed in the sequence.
2026-02-04 15:15:47 -06:00
func (sp *SeedProvider) Next() int64 {
return sp.rand.Int63()
}