Private
Public Access
1
0

big refactor
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Failing after 48s

This commit is contained in:
Sebastian Unterschütz
2025-11-25 18:11:47 +01:00
parent 6afcd4aa94
commit 732f507547
17 changed files with 1519 additions and 1295 deletions

27
rng.go Normal file
View File

@@ -0,0 +1,27 @@
package main
type PseudoRNG struct {
State uint32
}
func NewRNG(seed int64) *PseudoRNG {
return &PseudoRNG{State: uint32(seed)}
}
func (r *PseudoRNG) NextFloat() float64 {
calc := (uint64(r.State)*1664525 + 1013904223) % 4294967296
r.State = uint32(calc)
return float64(r.State) / 4294967296.0
}
func (r *PseudoRNG) NextRange(min, max float64) float64 {
return min + (r.NextFloat() * (max - min))
}
func (r *PseudoRNG) PickDef(defs []ObstacleDef) *ObstacleDef {
if len(defs) == 0 {
return nil
}
idx := int(r.NextRange(0, float64(len(defs))))
return &defs[idx]
}