From a81c39125fab7709ae08de78bd393c3bb4aad87e Mon Sep 17 00:00:00 2001 From: TabDragon <31097001+TabDragon@users.noreply.github.com> Date: Fri, 22 Dec 2017 22:47:14 +0100 Subject: [PATCH] Segmentation error fixed --- .../Layer1/AbstractionLayer_1.cpp | 17 ++++++++++------- Source/functions/solve/puzzleExtension.cpp | 7 ++++--- Source/functions/solve/structure.cpp | 2 +- Source/header/solve.h | 8 ++++++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp index e524f2c..5b120b0 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp @@ -36,11 +36,11 @@ bool AbstractionLayer_1::RemoveConstraintOnPosition(const coor constraintCoordin bool AbstractionLayer_1::CreateRandomPuzzle() { - std:: minstd_rand simple_rand; + std::minstd_rand simple_rand; simple_rand.seed((unsigned int)"dumbo"); - for(int col=1;col& PuzzleBox) void AbstractionLayer_1::setEdgeZero() { - for(int col=0;cola1->m_constraintMatrix[i][j]; + tmpPart.m_test1=this->a1.m_constraintMatrix[i][j]; //TODO! add all other layers here myBox.emplace_back(tmpPart); } @@ -36,14 +36,15 @@ void Puzzle::shuffle() //deletes all constraints from all abstractionlayers void Puzzle::removeConstrains(coor removeCoordinates) { - this->a1->RemoveConstraintOnPosition(removeCoordinates); + this->a1.RemoveConstraintOnPosition(removeCoordinates); } void Puzzle::createRandomPuzzle() { - a1->CreateRandomPuzzle(); + a1.CreateRandomPuzzle(); } void Puzzle::createp_box() { + } diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index fd66d7b..6a0cc51 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -73,7 +73,7 @@ void solve(vector& log, vector& p_Box, Puzzle& puzzleMat) switch(log.back().abstractionLevel) { case 1: - puzzleMat.a1->EvaluateQuality(log.back().myCoor, log.back().PieceCollector); + puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector); break; default: diff --git a/Source/header/solve.h b/Source/header/solve.h index 76ba6ba..674389b 100755 --- a/Source/header/solve.h +++ b/Source/header/solve.h @@ -39,13 +39,17 @@ private: class Puzzle { 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() {return {cols,rows};} DestructionPower* dp; - AbstractionLayer_1* a1; + AbstractionLayer_1 a1; void removeConstrains(coor removeCoordinates); void printPuzzle();