2024-02-06 01:41:20 +00:00
|
|
|
// uckf creates a deeply unsatisfying word search.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
)
|
|
|
|
|
|
|
|
var edgeSize = flag.Int("n", 8, "Cells per side")
|
|
|
|
|
|
|
|
type scanState int
|
|
|
|
const (
|
|
|
|
FuckIfIKnow scanState = iota
|
|
|
|
Fucked
|
|
|
|
NotFucked
|
|
|
|
)
|
|
|
|
|
|
|
|
type fuckness [3][3]scanState
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
var board [][]byte
|
|
|
|
for i := 0; i < *edgeSize; i++ {
|
|
|
|
fuckingRow := make([]byte, *edgeSize)
|
|
|
|
for j := 0; j < *edgeSize; j++ {
|
|
|
|
fuckingRow[j] = (i+j)%4
|
|
|
|
}
|
|
|
|
board=append(board, fuckingRow)
|
|
|
|
}
|
|
|
|
|
|
|
|
dump(board, "Starting position")
|
|
|
|
|
|
|
|
evals := [][]fuckness
|
|
|
|
for i := 0; i < *edgeSize; i++ {
|
|
|
|
evals = append(evals, make([]fuckness, *edgeSize))
|
|
|
|
}
|
|
|
|
|
|
|
|
iterations := uint64(0)
|
|
|
|
for(isStillFucked(board, evals)) {
|
|
|
|
fuckUp(board, evals)
|
|
|
|
iterations++
|
|
|
|
if isPow2(iterations) {
|
|
|
|
dump(board, fmt.Sprint("Iteration", iterations))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dump(board, "Not a single fuck")
|
|
|
|
}
|
|
|
|
|
|
|
|
func charAt(board [][]byte, i, j int) byte {
|
|
|
|
if i < 0 || j < 0 || i >= len(board) || j >= len(board[i]) {
|
|
|
|
return 5
|
|
|
|
}
|
|
|
|
return board[i][j]
|
|
|
|
}
|
|
|
|
|
|
|
|
func isStillFucked(board [][]byte, evals[][]fuckness) {
|
|
|
|
isFucked := false
|
|
|
|
for i, row := range board {
|
|
|
|
for j, c := range row {
|
|
|
|
for dr := -1; dr <= 1; dr++ {
|
|
|
|
for dc := -1; dc <= 1; dc++ {
|
|
|
|
if dr == 0 && dc == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if evals[i][j][dr+1][dc+1] != FuckIfIKnow {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// find theoretical start of fuck
|
|
|
|
fRow, fCol := i + int(c)*dr, j + int(c)*dr
|
|
|
|
// evaluate fuckness
|
|
|
|
locallyFucked := true
|
|
|
|
for w := 0; w < 4; w++ {
|
|
|
|
if charAt(board, i+w*dr, j+w*dc) != byte(w) {
|
|
|
|
locallyFucked = false
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if locallyFucked {
|
|
|
|
// mark every letter involved as fucked
|
|
|
|
isFucked = true
|
|
|
|
for w := 0; w < 4; w++ {
|
|
|
|
evals[i+w*dr][j+w*dc][dr+1][dc+1] = Fucked
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
evals[i][j][dr+1][dc+1] = NotFucked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isFucked
|
|
|
|
}
|
|
|
|
|
2024-02-06 01:46:09 +00:00
|
|
|
func isFucked(f fuckness) bool {
|
|
|
|
for i := 0; i <3; i++ {
|
|
|
|
for j := 0; j < 3; j++ {
|
|
|
|
if i == 1 && j == 1 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if f[i][j] == Fucked {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func mightBeFucked(f fuckness) bool {
|
|
|
|
for i := 0; i <3; i++ {
|
|
|
|
for j := 0; j < 3; j++ {
|
|
|
|
if i == 1 && j == 1 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if f[i][j] == NotFucked {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-02-06 01:41:20 +00:00
|
|
|
func fuckUp(board [][]byte, evals [][]fuckness) {
|
2024-02-06 01:46:09 +00:00
|
|
|
var todo [][2]int
|
|
|
|
for i, row := range evals {
|
|
|
|
for j, e := range row {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2024-02-06 01:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func dump(board [][]byte, title string) {
|
|
|
|
fmt.Println()
|
|
|
|
for i := 0; i < *edgeSize; i++ {
|
|
|
|
fmt.Print("--")
|
|
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
fmt.Println(title)
|
|
|
|
fmt.Println()
|
|
|
|
for _, row := range board {
|
|
|
|
for _, r := range row {
|
|
|
|
fmt.Printf("%c ", "fuck"[r])
|
|
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
}
|
|
|
|
}
|