additional flags: -s to summarize, -r=false to suppress final result

fun for seeing just how well it behaves on very large boards! it turns out printing the board is the slow part
This commit is contained in:
2024-02-05 19:48:45 -08:00
parent cb63c009cc
commit 691c59462a

31
uckf.go
View File

@ -9,7 +9,12 @@ import (
"math/rand"
)
var edgeSize = flag.Int("n", 15, "Cells per side")
var (
edgeSize = flag.Int("n", 15, "Cells per side")
summarize = flag.Bool("s", false, "Summarize when iterating")
showResult = flag.Bool("r", true, "Show final result (default true)")
)
type scanState int
const (
@ -43,14 +48,34 @@ func main() {
scream := uint64(0)
for(isStillFucked(board, evals)) {
if iterations >= scream {
dump(board, evals, fmt.Sprint("Iteration ", iterations))
if (*summarize) {
emitSummary(evals, iterations)
} else {
dump(board, evals, fmt.Sprint("Iteration ", iterations))
}
scream = iterations << 1
}
iterations++
fuckUp(board, evals)
}
dump(board, evals, fmt.Sprintf("Not a single fuck (%d iterations)", iterations))
if (*showResult) {
dump(board, evals, fmt.Sprintf("Not a single fuck (%d iterations)", iterations))
} else {
emitSummary(evals, iterations)
}
}
func emitSummary(evals [][]fuckness, iterations uint64) {
nFucked := uint64(0)
for _, row := range evals {
for _, e := range row {
if isFucked(e) {
nFucked++
}
}
}
fmt.Printf("Iteration %d: %d fucked (%.2f%%)\n", iterations, nFucked, 100 * float64(nFucked)/(float64(*edgeSize * *edgeSize)))
}
func onBoard(i, j int) bool {