Compare commits
2 Commits
2347ad523b
...
5bbf188285
Author | SHA1 | Date | |
---|---|---|---|
5bbf188285 | |||
b70e8d38de |
30
uckf.go
30
uckf.go
@ -9,7 +9,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
)
|
)
|
||||||
|
|
||||||
var edgeSize = flag.Int("n", 4, "Cells per side")
|
var edgeSize = flag.Int("n", 8, "Cells per side")
|
||||||
|
|
||||||
type scanState int
|
type scanState int
|
||||||
const (
|
const (
|
||||||
@ -34,25 +34,25 @@ func main() {
|
|||||||
board=append(board, fuckingRow)
|
board=append(board, fuckingRow)
|
||||||
}
|
}
|
||||||
|
|
||||||
dump(board, "Starting position")
|
|
||||||
|
|
||||||
var evals [][]fuckness
|
var evals [][]fuckness
|
||||||
for i := 0; i < *edgeSize; i++ {
|
for i := 0; i < *edgeSize; i++ {
|
||||||
evals = append(evals, make([]fuckness, *edgeSize))
|
evals = append(evals, make([]fuckness, *edgeSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump(board, evals, "Starting position")
|
||||||
|
|
||||||
iterations := uint64(0)
|
iterations := uint64(0)
|
||||||
scream := uint64(1)
|
scream := uint64(1)
|
||||||
for(isStillFucked(board, evals)) {
|
for(isStillFucked(board, evals)) {
|
||||||
fuckUp(board, evals)
|
|
||||||
iterations++
|
|
||||||
if iterations >= scream {
|
if iterations >= scream {
|
||||||
dump(board, fmt.Sprint("Iteration", iterations))
|
dump(board, evals, fmt.Sprint("Iteration", iterations))
|
||||||
scream = iterations << 1
|
scream = iterations << 1
|
||||||
}
|
}
|
||||||
|
iterations++
|
||||||
|
fuckUp(board, evals)
|
||||||
}
|
}
|
||||||
|
|
||||||
dump(board, "Not a single fuck")
|
dump(board, evals, "Not a single fuck")
|
||||||
}
|
}
|
||||||
|
|
||||||
func onBoard(i, j int) bool {
|
func onBoard(i, j int) bool {
|
||||||
@ -127,7 +127,7 @@ func mightBeFucked(f fuckness) bool {
|
|||||||
if i == 1 && j == 1 {
|
if i == 1 && j == 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if f[i][j] == NotFucked {
|
if f[i][j] != NotFucked {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ func fuckUp(board [][]byte, evals [][]fuckness) {
|
|||||||
if isFucked(e) {
|
if isFucked(e) {
|
||||||
todo = append(todo, [2]int{i, j})
|
todo = append(todo, [2]int{i, j})
|
||||||
} else if mightBeFucked(e) {
|
} else if mightBeFucked(e) {
|
||||||
dump(board, "Oh fuck")
|
dump(board, evals, "Oh fuck")
|
||||||
log.Fatalf("unevaluated fuckness at %d, %d: %v", i, j, e)
|
log.Fatalf("unevaluated fuckness at %d, %d: %v", i, j, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ func unevaluate(evals [][]fuckness, i, j int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dump(board [][]byte, title string) {
|
func dump(board [][]byte, evals [][]fuckness, title string) {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
for i := 0; i < *edgeSize; i++ {
|
for i := 0; i < *edgeSize; i++ {
|
||||||
fmt.Print("--")
|
fmt.Print("--")
|
||||||
@ -203,9 +203,13 @@ func dump(board [][]byte, title string) {
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println(title)
|
fmt.Println(title)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
for _, row := range board {
|
for i, row := range board {
|
||||||
for _, r := range row {
|
for j, r := range row {
|
||||||
fmt.Printf("%c ", "fuck"[r])
|
if isFucked(evals[i][j]) {
|
||||||
|
fmt.Printf("%c ", "FUCK"[r])
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%c ", "fuck"[r])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user