diff --git a/Codicil/Images/Balloons.jpg b/Codicil/Images/Balloons.jpg new file mode 100644 index 0000000..bbb4614 Binary files /dev/null and b/Codicil/Images/Balloons.jpg differ diff --git a/Codicil/Images/tiger.bmp b/Codicil/Images/tiger.bmp new file mode 100644 index 0000000..5e5e836 Binary files /dev/null and b/Codicil/Images/tiger.bmp differ diff --git a/Source/functions/solve/classExtension.cpp b/Source/functions/solve/classExtension.cpp index dd3bd46..bdef8e8 100755 --- a/Source/functions/solve/classExtension.cpp +++ b/Source/functions/solve/classExtension.cpp @@ -1,3 +1,4 @@ +#include "../../header.h" //shifts puzzle piece one to the right void PuzzlePiece::shift(unsigned int moves) @@ -189,7 +190,8 @@ void Puzzle::printPuzzle() } //creates a legal puzzle out of random pieces -void randomBox::createRandomPuzzle() + +void randomBox::createRandomAbstraction1() { PuzzlePiece temporaryRandomPiece(0); for(int i=0;i smallChannels; + unsigned int i=0,j=0; + for ( int y=0; y<=PuzzlePicture.rows-smallSize.height; y += smallSize.height ) + { + + for ( int x=0 ; x<=PuzzlePicture.cols-smallSize.width; x += smallSize.width ) + { + //split into different ROIs + cv::Rect rect = cv::Rect (x ,y , smallSize.width, smallSize.height ); + cv::Mat tmpSmallPicture = cv::Mat(PuzzlePicture,rect); + cv::split(tmpSmallPicture, smallChannels); + + //save color into individual PuzzlePieces in Matrix + PuzzlePiece tmpPiece = getPiece(j,i); + tmpPiece.r = cv::mean(smallChannels[0]).operator[](0); + tmpPiece.g = cv::mean(smallChannels[1]).operator[](0); + tmpPiece.b = cv::mean(smallChannels[2]).operator[](0); + setPiece(j,i,tmpPiece); + j++; + } + i++; + j=0; + } +} + +void randomBox::putAllIntoBox() { + for (int i = 0; i < getRows(); i++) + { + for (int j = 0; j < getCols(); j++) + { + Box.push_back(getPiece(j,i)); + } + } +} + //prints a box contents on console void randomBox::printBox() { shuffle(); - for (vector::iterator i = Box.begin(); i != Box.end(); i++) + for (vector::iterator i = Box.begin(); i != Box.end(); i++) { (*i).printPiece(); cout << ' '; - } + } cout << endl; } @@ -235,29 +284,37 @@ void randomBox::printBox() vector randomBox::shuffle() { random_shuffle(Box.begin(),Box.end()); - for (vector::iterator i = Box.begin(); i != Box.end(); i++) - (*i).shift(rand()%4); + for (vector::iterator i = Box.begin(); i != Box.end(); i++) + { + i->shift(rand()%4); + i->resetShift(); + } + numerateBox(Box); return Box; } //creates a random box size m, n, shuffles it, and then retuns it -vector createBox(unsigned int m, unsigned int n) +vector createBox(coor myCoor) { - randomBox myFirstPuzzleBox(m,n); - myFirstPuzzleBox.createRandomPuzzle(); - return myFirstPuzzleBox.shuffle(); + randomBox myFirstPuzzleBox(myCoor.m,myCoor.n); + myFirstPuzzleBox.createRandomAbstraction1(); + myFirstPuzzleBox.createRandomAbstraction2(); + myFirstPuzzleBox.putAllIntoBox(); + + myFirstPuzzleBox.printPuzzle(); + return myFirstPuzzleBox.shuffle(); } //prints contents of box void printBox(vector myBox) { cout << "current Box: " << endl; - for (vector::iterator i = myBox.begin(); i != myBox.end(); i++) + for (vector::iterator i = myBox.begin(); i != myBox.end(); i++) { (*i).printPiece(); cout << ' '; - } + } cout << endl; return; } diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index fb94944..63d3641 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -1,3 +1,5 @@ +#include "../../header.h" + void status(vector& log, vector& p_Box, Puzzle& puzzleMat); @@ -66,15 +68,6 @@ bool next(vector& log, vector& p_Box, Puzzle& puzzleMat) return 1; } -/* -coor calculateFirstCoor(vector& log, vector& p_Box, Puzzle& puzzleMat) -{ - //returns coor of first piece - coor firstCoor(0,0); - return firstCoor; -} -*/ - coor calculateNextCoor(vector& log, vector& p_Box, Puzzle& puzzleMat) { //level 1: @@ -135,10 +128,10 @@ void abstractionlayer1solver(vector& log, vector& p_Box, log.back().PieceCollector.erase(log.back().PieceCollector.begin()+i); else { - i++; //otherwise loop stops before end! //set shift to 0 so that we have a defined starting position for all pieces while(log.back().PieceCollector[i]->getShift()) log.back().PieceCollector[i]->shift(1); + i++; //otherwise loop stops before end! } } } diff --git a/Source/header.h b/Source/header.h index 75f46ae..49ba840 100755 --- a/Source/header.h +++ b/Source/header.h @@ -5,15 +5,10 @@ #include #include +#define MAX_ABSTRAX 1 +#define structdebug using namespace std; #include "header/input.h" #include "header/solve.h" -#include "header/output.h" - -#include "functions/input/input.cpp" -#include "functions/solve/classExtension.cpp" -#include "functions/solve/structure.cpp" -#include "functions/output/output.cpp" - diff --git a/Source/header/input.h b/Source/header/input.h index f93c63c..7a16bd8 100755 --- a/Source/header/input.h +++ b/Source/header/input.h @@ -3,6 +3,10 @@ class Part { public: + double r; + double g; + double b; + Part(): connections(0){} ~Part() {} uint8_t getConnections() const @@ -13,4 +17,6 @@ public: private: uint8_t connections; + + }; \ No newline at end of file diff --git a/Source/header/solve.h b/Source/header/solve.h index efce116..7c8d189 100755 --- a/Source/header/solve.h +++ b/Source/header/solve.h @@ -1,6 +1,10 @@ +#include +#include +#include +#include + using namespace std; - class PuzzlePiece: public Part { public: @@ -114,8 +118,10 @@ 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(); + + void createRandomAbstraction1(); + void createRandomAbstraction2(); + void putAllIntoBox(); vector shuffle(); void printBox(); @@ -157,24 +163,11 @@ private: static int randomed; }; -class BoxClassify -{ - vector p_Box; - vector> ab1class; - - -}; - -int LogEntry::randomed(0); -unsigned int PuzzlePiece::idcount(0); - - void printBox(vector myBox); -vector createBox(unsigned int m, unsigned int n); +vector createBox(coor myCoor); 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); diff --git a/Source/main.cpp b/Source/main.cpp index f2bf530..ae94bb3 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -1,39 +1,22 @@ -#define MAX_ABSTRAX 1 -#define structdebug - - #include "header.h" -//#include "../Codicil/test_puzzle_long40x40.h" + +int LogEntry::randomed(0); +unsigned int PuzzlePiece::idcount(0); int main() { - int cols=10, rows=20; - //some basic part stuff - vector myFirstPuzzle; - Part myFirstPart; - myFirstPart.setConnections(0b00101000); - myFirstPuzzle.push_back(myFirstPart); + int cols=2, rows=3; //some basic random puzzle stuff - randomBox myRandomBox(cols,rows); - myRandomBox.createRandomPuzzle(); - vector myFirstBox = myRandomBox.shuffle(); - - //undo everything and make this puzzle fucking imba hard!!! - //need 40x40 for this, so check your status - - //makehard4040puzzle(myFirstBox); + vector myFirstBox = createBox(coor(cols,rows)); //some advanced solver stuff vector log; vector p_myFirstBox; //BoxClassify myFirstBox(); - - cout << "original puzzle: " << endl; - myRandomBox.printPuzzle(); cout << endl; for(int i=0;i