// bedlam.cpp - program to solve Bedlam puzzle, print solutions

#include "search.hpp"
#include "box.h"

// class Bedlam - solve Bedlam puzzle, print solutions
class Bedlam {

private:

// box - the box puzzle
box::Box box;

// searchserver - search server with 64 locations
search::Server<search::PosFixed<64> > searchserver;

// shapes - puzzle shape data
Shapes shapes;

public:

// Bedlam - initialize Bedlam puzzle
Bedlam(void) : box(3, 4), shapes(13)
{
	int shape1[] = { 0, 1, 2, 18, 22 };
	int shape2[] = { 0, 1, 2, 5, 21 };
	int shape3[] = { 0, 1, 5, 6, 21 };
	int shape4[] = { 0, 1, 2, 5, 16 };
	int shape5[] = { 0, 1, 5, 21 };
	int shape6[] = { 0, 1, 5, 6, 10 };
	int shape7[] = { 0, 1, 2, 5, 17 };
	int shape8[] = { 1, 4, 5, 6, 9 };
	int shape9[] = { 0, 1, 5, 6, 9 };
	int shape10[] = { 0, 1, 5, 6, 16 };
	int shape11[] = { 0, 1, 5, 21, 22 };
	int shape12[] = { 0, 1, 2, 4, 16 };
	int shape13[] = { 0, 1, 2, 6, 16 };

	shapes[0] = Shape(1, Pos(shape1 + 0, shape1 + 5));
	shapes[1] = Shape(1, Pos(shape2 + 0, shape2 + 5));
	shapes[2] = Shape(1, Pos(shape3 + 0, shape3 + 5));
	shapes[3] = Shape(1, Pos(shape4 + 0, shape4 + 5));
	shapes[4] = Shape(1, Pos(shape5 + 0, shape5 + 4));
	shapes[5] = Shape(1, Pos(shape6 + 0, shape6 + 5));
	shapes[6] = Shape(1, Pos(shape7 + 0, shape7 + 5));
	shapes[7] = Shape(1, Pos(shape8 + 0, shape8 + 5));
	shapes[8] = Shape(1, Pos(shape9 + 0, shape9 + 5));
	shapes[9] = Shape(1, Pos(shape10 + 0, shape10 + 5));
	shapes[10] = Shape(1, Pos(shape11 + 0, shape11 + 5));
	shapes[11] = Shape(1, Pos(shape12 + 0, shape12 + 5));
	shapes[12] = Shape(1, Pos(shape13 + 0, shape13 + 5));
}

// run - solve Bedlam puzzle, print solutions
void run(void)
{
	box.setshapes(shapes);
	box.setreflectout(true);
	box.search(searchserver);
	box.print(std::cout, "ABCDEFGHIJKLM", "ABCDEFGHIJKLM");
}

}; // end of class Bedlam

// main - solve Bedlam puzzle, print solutions
int main(void)

{
	Bedlam().run();
	return (0);
}
