Description
The current implementation of PCGSource
has a number of missing features, mostly related to control over the seeding process. The Seed()
method even has a TODO
in it:
// Seed uses the provided seed value to initialize the generator to a deterministic state.
func (pcg *PCGSource) Seed(seed uint64) {
pcg.low = seed
pcg.high = seed // TODO: What is right?
}
Similarly, there's no way to get access to the current seed data.
Bikeshed Color 1
I propose adding a new function and two methods:
func NewPCGSource(high, low uint64) *PCGSource
func (pcg *PCGSource) SeedPCG(high, low uint64)
func (pcg *PCGSource) PCG() (high, low uint64)
This would give much greater control over the source.
Bikeshed Color 2
Alternatively, I recently copied the existing implementation in order to remove the internal state from it completely for a somewhat specific use case. I replaced the entire system with single function, func Next(high, low uint64) (n, nhigh, nlow uint64)
, that gave me full control over the generation.
If such a function was added, the existing implementation could easily be changed to just call any such function instead:
func (pcg *PCGSource) Uint64() (n uint64) {
n, pcg.high, pcg.low = NextPCG(pcg.high, pcg.low)
return
}
Summary
I'm bikeshedding a bit, but my only point is that I'd like some greater control over the PCGSource
implementation's seeding process.