Compare commits
4 Commits
5bbf188285
...
main
Author | SHA1 | Date | |
---|---|---|---|
ff9c8315c1
|
|||
691c59462a
|
|||
cb63c009cc
|
|||
281cb218b3
|
17
README.md
17
README.md
@ -1,3 +1,20 @@
|
||||
# uckf
|
||||
|
||||
A deeply unsatisfying word search.
|
||||
|
||||
## Usage
|
||||
|
||||
1. [install the Go compiler](https://go.dev/dl/) if you don't have it yet
|
||||
2. clone this repo (`git clone https://git.chromaticdragon.app/kistaro/uckf.git`)
|
||||
3. `go run uckf.go`
|
||||
4. you can use `-n` to specify a different grid size; for example, `go run uckf.go -n 100` will create a 100x100 unsatisfying word search
|
||||
|
||||
### Flags
|
||||
|
||||
* `-n <int>` -- use a grid with edges of length n
|
||||
* `-s` -- summary mode; do not print intermediate grids, only summaries
|
||||
* `-r=false` -- suppress final result (only print a summary for that)
|
||||
|
||||
## Notes
|
||||
|
||||
This algorithm converges much more quickly than I expected.
|
||||
|
35
uckf.go
35
uckf.go
@ -9,7 +9,12 @@ import (
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
var edgeSize = flag.Int("n", 8, "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 (
|
||||
@ -39,20 +44,38 @@ func main() {
|
||||
evals = append(evals, make([]fuckness, *edgeSize))
|
||||
}
|
||||
|
||||
dump(board, evals, "Starting position")
|
||||
|
||||
iterations := uint64(0)
|
||||
scream := uint64(1)
|
||||
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, "Not a single fuck")
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user