Ending game automatically when statis is reached
plus properly seeding math/rand and swapping the chars used for grid to better match black/white from canonical example.
This commit is contained in:
@@ -29,15 +29,27 @@ func main() {
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
cksum := game.Checksum()
|
||||
|
||||
ticks := time.Tick(time.Duration(*sleepMs) * time.Millisecond)
|
||||
generations := 0
|
||||
for now := range ticks {
|
||||
fmt.Printf("\nGeneration %v\n%v\n", generations, now)
|
||||
fmt.Println(game)
|
||||
|
||||
game.EvaluateGeneration()
|
||||
|
||||
if cksum == game.Checksum() {
|
||||
fmt.Println("Stasis!")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
cksum = game.Checksum()
|
||||
|
||||
if *mutate && generations%2 == 0 {
|
||||
game.Mutate()
|
||||
}
|
||||
|
||||
generations++
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user