|
|
@ -7,8 +7,13 @@ import (
|
|
|
|
"math"
|
|
|
|
"math"
|
|
|
|
"math/rand"
|
|
|
|
"math/rand"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
|
|
rand.Seed(time.Now().UTC().UnixNano())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type GameOfLife struct {
|
|
|
|
type GameOfLife struct {
|
|
|
|
State *GameState
|
|
|
|
State *GameState
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -159,6 +164,10 @@ func (state *GameState) Mutate() error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (game *GameOfLife) Checksum() string {
|
|
|
|
|
|
|
|
return game.State.Checksum()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (state *GameState) Checksum() string {
|
|
|
|
func (state *GameState) Checksum() string {
|
|
|
|
ck := sha1.New()
|
|
|
|
ck := sha1.New()
|
|
|
|
cells := make(chan *GameStateCell)
|
|
|
|
cells := make(chan *GameStateCell)
|
|
|
@ -282,7 +291,7 @@ func (state *GameState) String() string {
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if value == 0 {
|
|
|
|
if value == 1 {
|
|
|
|
stringVal = "·"
|
|
|
|
stringVal = "·"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cells = append(cells, stringVal)
|
|
|
|
cells = append(cells, stringVal)
|
|
|
|