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:
parent
6fa2da2f01
commit
e94d758a9b
12 changed files with 479 additions and 52 deletions
20
rand.go
20
rand.go
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue