Segmentation error fixed
This commit is contained in:
parent
bfed4aba05
commit
a81c39125f
@ -36,11 +36,11 @@ bool AbstractionLayer_1::RemoveConstraintOnPosition(const coor constraintCoordin
|
|||||||
|
|
||||||
bool AbstractionLayer_1::CreateRandomPuzzle()
|
bool AbstractionLayer_1::CreateRandomPuzzle()
|
||||||
{
|
{
|
||||||
std:: minstd_rand simple_rand;
|
std::minstd_rand simple_rand;
|
||||||
simple_rand.seed((unsigned int)"dumbo");
|
simple_rand.seed((unsigned int)"dumbo");
|
||||||
|
|
||||||
for(int col=1;col<m_constraintMatrix.size()-1;col++){
|
for(int col = 1; col < m_constraintMatrix.size()-1; col++){
|
||||||
for(int row=1;row<m_constraintMatrix[col].size()-1;)
|
for(int row = 1; row < (m_constraintMatrix[col].size() - 1);)
|
||||||
{
|
{
|
||||||
//create random piece
|
//create random piece
|
||||||
uint8_t tempPiece = 0b00000000;
|
uint8_t tempPiece = 0b00000000;
|
||||||
@ -76,7 +76,10 @@ bool AbstractionLayer_1::CreateRandomPuzzle()
|
|||||||
|
|
||||||
//set piece if piece good
|
//set piece if piece good
|
||||||
if(PlaceOfPartGood(coor(col,row),tempPiece))
|
if(PlaceOfPartGood(coor(col,row),tempPiece))
|
||||||
row++;
|
{
|
||||||
|
row++; // Sollte er hier nicht das Puzzleteil irgendwo abspeichern? Weiß aber nicht ob die constraint layer der richtige platz ist, oder nicht eine neue, bzw. die puzzlebox
|
||||||
|
m_constraintMatrix[col][row].m_connections = tempPiece;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,9 +101,9 @@ qualityVector AbstractionLayer_1::returnInBox(vector<Part>& PuzzleBox)
|
|||||||
|
|
||||||
void AbstractionLayer_1::setEdgeZero()
|
void AbstractionLayer_1::setEdgeZero()
|
||||||
{
|
{
|
||||||
for(int col=0;col<m_constraintMatrix.size();col++)
|
for(int col = 0; col < m_constraintMatrix.size(); col++)
|
||||||
for(int row=0;row<m_constraintMatrix[col].size();row++)
|
for(int row = 0; row < m_constraintMatrix[col].size(); row++)
|
||||||
if(col ==0 || col == m_constraintMatrix.size() || row == 0 || row == m_constraintMatrix[col].size())
|
if(col == 0 || col == (m_constraintMatrix.size() - 1) || row == 0 || row == (m_constraintMatrix[col].size() - 1))
|
||||||
m_constraintMatrix[col][row].m_connections=0b00000000;
|
m_constraintMatrix[col][row].m_connections=0b00000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ void Puzzle::putIntoBox()
|
|||||||
{
|
{
|
||||||
//TODO! add rotation of all parts
|
//TODO! add rotation of all parts
|
||||||
//TODO! add id to every part (how)
|
//TODO! add id to every part (how)
|
||||||
tmpPart.m_test1=this->a1->m_constraintMatrix[i][j];
|
tmpPart.m_test1=this->a1.m_constraintMatrix[i][j];
|
||||||
//TODO! add all other layers here
|
//TODO! add all other layers here
|
||||||
myBox.emplace_back(tmpPart);
|
myBox.emplace_back(tmpPart);
|
||||||
}
|
}
|
||||||
@ -36,14 +36,15 @@ void Puzzle::shuffle()
|
|||||||
//deletes all constraints from all abstractionlayers
|
//deletes all constraints from all abstractionlayers
|
||||||
void Puzzle::removeConstrains(coor removeCoordinates)
|
void Puzzle::removeConstrains(coor removeCoordinates)
|
||||||
{
|
{
|
||||||
this->a1->RemoveConstraintOnPosition(removeCoordinates);
|
this->a1.RemoveConstraintOnPosition(removeCoordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Puzzle::createRandomPuzzle()
|
void Puzzle::createRandomPuzzle()
|
||||||
{
|
{
|
||||||
a1->CreateRandomPuzzle();
|
a1.CreateRandomPuzzle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Puzzle::createp_box()
|
void Puzzle::createp_box()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ void solve(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
|||||||
switch(log.back().abstractionLevel)
|
switch(log.back().abstractionLevel)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
puzzleMat.a1->EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
|
puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -39,13 +39,17 @@ private:
|
|||||||
class Puzzle
|
class Puzzle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Puzzle(unsigned int newcols,unsigned int newrows):rows(newrows),cols(newcols){}
|
Puzzle(unsigned int newcols,unsigned int newrows):rows(newrows),cols(newcols)
|
||||||
|
{
|
||||||
|
a1.InitialiseConstraintMatrixSize(newcols+2, newrows+2);
|
||||||
|
a1.setEdgeZero();
|
||||||
|
}
|
||||||
|
|
||||||
coor getSizeAsCoor()
|
coor getSizeAsCoor()
|
||||||
{return {cols,rows};}
|
{return {cols,rows};}
|
||||||
|
|
||||||
DestructionPower* dp;
|
DestructionPower* dp;
|
||||||
AbstractionLayer_1* a1;
|
AbstractionLayer_1 a1;
|
||||||
|
|
||||||
void removeConstrains(coor removeCoordinates);
|
void removeConstrains(coor removeCoordinates);
|
||||||
void printPuzzle();
|
void printPuzzle();
|
||||||
|
Loading…
Reference in New Issue
Block a user