improved random generator, made information call from Part more direct

todo: add indexing to puzzlepieces and all four rotation into puzzlebox (or maybe only log?). this needs to be done for random algorithm and for realPuzzle
This commit is contained in:
Raphael Maenle 2017-12-21 13:07:01 +01:00
parent bd07d291db
commit 86c4e26bc7
6 changed files with 40 additions and 24 deletions

View File

@ -18,7 +18,7 @@ bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, quali
{
for(auto it = qVector.begin(); it != qVector.end(); it++)
{
if(PlaceOfPartGood(constraintCoordinate, it->first->myLayers->m_test1.m_connections))
if(PlaceOfPartGood(constraintCoordinate, it->first->m_test1.m_connections))
continue;
qVector.erase(it++);
}
@ -92,7 +92,7 @@ qualityVector AbstractionLayer_1::returnInBox(vector<Part>& PuzzleBox)
int i=0;
for(int col=1;col<m_constraintMatrix.size()-1;col++)
for(int row=1;row<m_constraintMatrix[col].size()-1;row++)
PuzzleBox[i++].myLayers->m_test1.m_connections=m_constraintMatrix[col][row].m_connections;
PuzzleBox[i++].m_test1.m_connections=m_constraintMatrix[col][row].m_connections;
}

View File

@ -17,4 +17,7 @@ private:
};
#endif //SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H

View File

@ -5,25 +5,45 @@
#include "../../header/solve.h"
void Puzzle::printPuzzle() {}
void Puzzle::putIntoBox() {}//puts a puzzlepiece back into its box
void Puzzle::printPuzzle()
{
//print every layer individually for now and later make complete visual
}
//puts a puzzlepiece back into its box
void Puzzle::putIntoBox()
{
Part tmpPart;
for(int i=0;i<this->getSizeAsCoor().col;i++)
{
for(int j=0;j<this->getSizeAsCoor().row;j++)
{
//TODO! add rotation of all parts
//TODO! add id to every part (how)
tmpPart.m_test1=this->a1->m_constraintMatrix[i][j];
//TODO! add all other layers here
myBox.emplace_back(tmpPart);
}
}
}
//shuffles the existing box in Puzzle
void Puzzle::shuffle()
{
random_shuffle(myBox.begin(),myBox.end());
for (auto &i:myBox)
}
//deletes all constraints from all abstractionlayers
void Puzzle::removeConstrains(coor removeCoordinates)
{
//i.myLayers->m_test1
//shift(rand()%4,i);
//i.resetShift();
this->a1->RemoveConstraintOnPosition(removeCoordinates);
}
}
void Puzzle::removeConstrains(coor removeCoordinates) {}//deletes all constraints from all abstractionlayers
void Puzzle::createRandomPuzzle()
{
a1->CreateRandomPuzzle();
}
void Puzzle::createp_box()
{
}

View File

@ -38,7 +38,8 @@ public:
m_numOfRotations = numOfRotations;
}
LayerContainer* myLayers;
AbstractionLayer_1_Properties m_test1;
DestructionPower_Properties m_destruction;
private:
int32_t m_partID;
uint8_t m_numOfRotations;

View File

@ -50,10 +50,11 @@ public:
void removeConstrains(coor removeCoordinates);
void printPuzzle();
void createRandomBox(){createRandomPuzzle();putIntoBox();shuffle();}
void createRandomBox(){createRandomPuzzle();putIntoBox();shuffle();createp_box();}
void createRandomPuzzle();
void putIntoBox();
void shuffle();
void createp_box();
vector<Part> myBox;
vector<Part*> p_myBox;
@ -64,14 +65,6 @@ private:
unsigned int cols;
};
class LayerContainer
{
public:
AbstractionLayer_1_Properties m_test1;
DestructionPower_Properties m_destruction;
};
bool next(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
coor calculateNextCoor(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
void solve(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);

View File

@ -13,7 +13,6 @@ int main()
//some advanced solver stuff
vector<LogEntry> log;
vector<Part*> p_myFirstBox;
Puzzle puzzleMat(cols, rows);
puzzleMat.createRandomBox();