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:
parent
cb63c009cc
commit
691c59462a
27
uckf.go
27
uckf.go
@ -9,7 +9,12 @@ import (
|
|||||||
"math/rand"
|
"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
|
type scanState int
|
||||||
const (
|
const (
|
||||||
@ -43,14 +48,34 @@ func main() {
|
|||||||
scream := uint64(0)
|
scream := uint64(0)
|
||||||
for(isStillFucked(board, evals)) {
|
for(isStillFucked(board, evals)) {
|
||||||
if iterations >= scream {
|
if iterations >= scream {
|
||||||
|
if (*summarize) {
|
||||||
|
emitSummary(evals, iterations)
|
||||||
|
} else {
|
||||||
dump(board, evals, fmt.Sprint("Iteration ", iterations))
|
dump(board, evals, fmt.Sprint("Iteration ", iterations))
|
||||||
|
}
|
||||||
scream = iterations << 1
|
scream = iterations << 1
|
||||||
}
|
}
|
||||||
iterations++
|
iterations++
|
||||||
fuckUp(board, evals)
|
fuckUp(board, evals)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*showResult) {
|
||||||
dump(board, evals, fmt.Sprintf("Not a single fuck (%d iterations)", iterations))
|
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 {
|
func onBoard(i, j int) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user