using namespace std; class PuzzlePiece: public Part { public: PuzzlePiece(unsigned int flag = 0) { shifts=0; boxidentifier=-1; switch(flag) { case 0: setConnections(0b00000000); break; case 1: setConnections(0b11111111); break; case 3: randomCenterPiece(); break; } } void shift(unsigned int moves); void randomCenterPiece(); void printPiece() { cout << bitset (getConnections()); } void setBoxIdentifier(int new_boxid) { boxidentifier = new_boxid; } int getBoxIdentifier() { return boxidentifier; } void assignIdentifier() { identifier = idcount;idcount++; } unsigned int getIdentifier() { return identifier;} private: unsigned int shifts; unsigned int boxidentifier; unsigned int identifier; static unsigned int idcount; }; class Puzzle { friend class randomBox; public: //constructor creates matrix with 00 outside and 11 inside Puzzle(uint m = 7, uint n = 4): col(m), row(n) { Matrix = new PuzzlePiece* [n+2]; for(int i = 0;i& myBox, unsigned int separator); unsigned int putBackIntoBox(unsigned int m, unsigned int n, vector& myBox); private: uint row; uint col; PuzzlePiece** Matrix; }; //use this for random puzzle creation class randomBox: public Puzzle { public: randomBox(unsigned int m, unsigned int n) : Puzzle(m,n) {srand(time(0));} //passed m n to puzzle constructor void createRandomPuzzle(); vector shuffle(); void printBox(); private: vector Box; }; class coor { public: int m, n; coor(int newm=-1,int newn=-1): m(newm), n(newn) {} }; class LogEntry { public: vector PieceCollector; int abstractionLevel; coor myCoor; void advance(){abstractionLevel++;} void Set(){set=1;} bool isSet(){return set;} void advanceRandomed() { randomed++;} void decreaseRandomed() { randomed--;} int hasRandomed(){return randomed;} LogEntry() { myCoor = coor(); abstractionLevel=0; set=0; } private: bool set; static int randomed; }; int LogEntry::randomed(0); unsigned int PuzzlePiece::idcount(0); void printBox(vector myBox); vector createBox(uint m, uint n); void numerateBox(vector& myBox); bool next(vector& log, vector& p_Box, Puzzle& puzzleMat); coor calculateFirstCoor(vector& log, vector& p_Box, Puzzle& puzzleMat); coor calculateNextCoor(vector& log, vector& p_Box, Puzzle& puzzleMat); void solve(vector& log, vector& p_Box, Puzzle& puzzleMat); void abstractionlayer0solver(vector& log, vector& p_Box, Puzzle& puzzleMat); void abstractionlayer1solver(vector& log, vector& p_Box, Puzzle& puzzleMat); void setsolution(vector& log, vector& p_Box, Puzzle& puzzleMat); bool backtrack(vector& log, vector& p_Box, Puzzle& puzzleMat);