Select Git revision
Tóth Miklós Tibor authored
cgol.go 998 B
package main
import (
"github.com/samber/lo"
"pp/pkg/tutter"
"simonwaldherr.de/go/cgolGo/life"
"strings"
"time"
)
func main() {
field := life.GenerateFirstRound(8, 8)
prevF := ""
for {
cells := field.GetCells()
rows := lo.Map(cells, func(row []int, _ int) string {
strs := lo.Map(row, func(item int, _ int) string {
if item != 0 {
return "⬛"
} else {
return "⬜"
}
})
return strings.Join(strs, "")
})
f := strings.Join(rows, "\n")
f = "#cgol\n" + f
e := tutter.Send(f)
if e != nil {
panic(e)
}
if prevF == f {
e = tutter.Send(`#cgol
Board is stable. I'll go grab a covfefe.`)
if e != nil {
panic(e)
}
field = life.GenerateFirstRound(8, 8)
}
prevF = f
time.Sleep(time.Second)
alive := strings.Contains(f, "⬛")
if !alive {
e = tutter.Send(`#cgol
Board is dead!!! I go brrr.`)
if e != nil {
panic(e)
}
field = life.GenerateFirstRound(8, 8)
}
field = field.NextRound()
}
}