DEV 1303: Add empty and royale maps and update game map interface (#72)

* move random generator into Settings

* add empty and royale maps

* place snakes on either cardinal or corner positions first
This commit is contained in:
Rob O'Dwyer 2022-05-17 15:45:56 -07:00 committed by GitHub
parent 6fa2da2f01
commit e94d758a9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 479 additions and 52 deletions

20
rand.go
View file

@ -20,6 +20,26 @@ func (globalRand) Shuffle(n int, swap func(i, j int)) {
rand.Shuffle(n, swap)
}
type seedRand struct {
seed int64
rand *rand.Rand
}
func NewSeedRand(seed int64) *seedRand {
return &seedRand{
seed: seed,
rand: rand.New(rand.NewSource(seed)),
}
}
func (s seedRand) Intn(n int) int {
return s.rand.Intn(n)
}
func (s seedRand) Shuffle(n int, swap func(i, j int)) {
s.rand.Shuffle(n, swap)
}
// For testing purposes
// A Rand implementation that always returns the minimum value for any method.