9 import "github.com/petar/GoLLRB/llrb"
10 import "github.com/willf/bloom"
12 var bloomsize = flag.Int("bloomsize", 2000000, "Size bloomfilter for this many states.")
16 const BOARD_SIZE = BOARD_DIM * BOARD_DIM
19 type Board [BOARD_SIZE]Space
33 func read_board_from_strings(in []string) (*Board, error) {
34 if len(in) != BOARD_SIZE {
35 return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE)
38 for i, s := range in {
39 num, err := strconv.Atoi(s)
48 func adjacent_spaces(s Space) []Space {
49 if s < 0 || s >= BOARD_SIZE {
50 panic("Invalid space")
54 adjacent = append(adjacent, s+UP)
56 if s < BOARD_SIZE-BOARD_DIM {
57 adjacent = append(adjacent, s+DOWN)
60 adjacent = append(adjacent, s+LEFT)
62 if s%BOARD_DIM != BOARD_DIM-1 {
63 adjacent = append(adjacent, s+RIGHT)
68 func create_successors(start *Step) {
69 for _, adj := adjacent_spaces(start.
72 func sliding_tile(start *Board) error {
73 seen := bloom.NewWithEstimates(uint(*bloomsize), 0.0001)
74 seen.Add(reflect.ValueOf(*start).Bytes())
80 start, err := read_board_from_strings(flag.Args())
85 err = sliding_tile(start)