package main
+import "flag"
import "fmt"
import "os"
+import "reflect"
import "strconv"
+import "github.com/petar/GoLLRB/llrb"
+import "github.com/willf/bloom"
+
+var bloomsize = flag.Int("bloomsize", 2000000, "Size bloomfilter for this many states.")
+
const HOLE = 0
-const BOARD_SIZE = 16
+const BOARD_DIM = 4
+const BOARD_SIZE = BOARD_DIM * BOARD_DIM
type Space int8
type Board [BOARD_SIZE]Space
+type Step struct {
+ board Board
+ prev *Step
+ length int
+}
+
+const (
+ LEFT = -1
+ RIGHT = +1
+ UP = -BOARD_DIM
+ DOWN = +BOARD_DIM
+)
func read_board_from_strings(in []string) (*Board, error) {
if len(in) != BOARD_SIZE {
return &b, nil
}
+func adjacent_spaces(s Space) []Space {
+ if s < 0 || s >= BOARD_SIZE {
+ panic("Invalid space")
+ }
+ var adjacent []Space
+ if s >= BOARD_DIM {
+ adjacent = append(adjacent, s+UP)
+ }
+ if s < BOARD_SIZE-BOARD_DIM {
+ adjacent = append(adjacent, s+DOWN)
+ }
+ if s%BOARD_DIM != 0 {
+ adjacent = append(adjacent, s+LEFT)
+ }
+ if s%BOARD_DIM != BOARD_DIM-1 {
+ adjacent = append(adjacent, s+RIGHT)
+ }
+ return adjacent
+}
+
+func create_successors(start *Step) {
+ for _, adj := adjacent_spaces(start.
+}
+
+func sliding_tile(start *Board) error {
+ seen := bloom.NewWithEstimates(uint(*bloomsize), 0.0001)
+ seen.Add(reflect.ValueOf(*start).Bytes())
+ return nil
+}
+
func main() {
- start, err := read_board_from_strings(os.Args[1:])
+ flag.Parse()
+ start, err := read_board_from_strings(flag.Args())
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ err = sliding_tile(start)
if err != nil {
- panic(err)
+ fmt.Println(err)
+ os.Exit(1)
}
- fmt.Println(start)
}