Detecting 3-period oscillators
and properly (?) checking for zero-oscillator stasis.
This commit is contained in:
parent
78625088e8
commit
f22abc0430
@ -20,11 +20,12 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func pushChecksum(checksum string, checksums []string) {
|
func pushChecksum(checksum string, checksums []string) {
|
||||||
first2 := make([]string, 2)
|
head := make([]string, 3)
|
||||||
copy(first2, checksums[:2])
|
copy(head, checksums[:3])
|
||||||
checksums[0] = checksum
|
checksums[0] = checksum
|
||||||
checksums[1] = first2[0]
|
checksums[1] = head[0]
|
||||||
checksums[2] = first2[1]
|
checksums[2] = head[1]
|
||||||
|
checksums[3] = head[2]
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -37,8 +38,8 @@ func main() {
|
|||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
checksums := make([]string, 3)
|
checksums := make([]string, 4)
|
||||||
checksums[0], checksums[1], checksums[2] = "foo", "bar", "baz"
|
checksums[0], checksums[1], checksums[2], checksums[3] = "foo", "bar", "baz", "qwx"
|
||||||
pushChecksum(game.Checksum(), checksums)
|
pushChecksum(game.Checksum(), checksums)
|
||||||
|
|
||||||
ticks := time.Tick(time.Duration(*sleepMs) * time.Millisecond)
|
ticks := time.Tick(time.Duration(*sleepMs) * time.Millisecond)
|
||||||
@ -51,14 +52,20 @@ func main() {
|
|||||||
|
|
||||||
curChecksum := game.Checksum()
|
curChecksum := game.Checksum()
|
||||||
|
|
||||||
if checksums[0] == curChecksum {
|
if checksums[0] == curChecksum || checksums[1] == curChecksum {
|
||||||
fmt.Println("Stasis!")
|
fmt.Println("Stasis!")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if checksums[1] == curChecksum || checksums[2] == curChecksum {
|
if checksums[2] == curChecksum {
|
||||||
fmt.Println("Checksum found in last 2")
|
fmt.Println("Checksum found 2 periods ago")
|
||||||
fmt.Println("Stasis with blinkers or beacons or some such!")
|
fmt.Println("Stasis with 2-period oscillator(s)!")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if checksums[3] == curChecksum {
|
||||||
|
fmt.Println("Checksum found 3 periods ago")
|
||||||
|
fmt.Println("Stasis with 3-period oscillator(s)!")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user