Beispiel #1
0
func GetMap(size int, heur int) (*board.Board, error) {
	var err error

	if size < 3 {
		size = 3
	}
	b := board.New(size, heur)
	sVal := Get_slice(size)
	for i := 0; i < b.Size; i++ {
		for j := 0; j < b.Size; j++ {
			sVal, b.Tiles[i*b.Size+j] = Get_Value(sVal)
			if b.Tiles[i*b.Size+j] == 0 {
				b.BR = i
				b.BC = j
			}
		}
	}
	if b.CheckBoard() == false {
		b, err = GetMap(size, heur)
		if err != nil {
			return nil, err
		}
	}
	return b, nil
}
Beispiel #2
0
func BenchmarkSolve(bench *testing.B) {
	inp := []int{
		1, 2, 3,
		4, 8, 6,
		7, 5, 0,
	}
	b := board.New(3)
	b.Input(inp)
	s := New(b)
	for i := 0; i < bench.N; i++ {
		s.Solve()
	}

}