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:
Dan Buch
2012-12-10 00:35:09 -05:00
parent ad1bd2537a
commit 3ff6e2e999
2 changed files with 22 additions and 1 deletions

View File

@@ -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++
}
}