From c0f0417d3b6fe6c30f3fe9e77d29e53533e56c6e Mon Sep 17 00:00:00 2001 From: Raphael Maenle <17550607+g-spacewhale@users.noreply.github.com> Date: Mon, 8 Jan 2018 18:33:30 +0100 Subject: [PATCH] dispatcher-a1 now functional a1 Solver finds solutions for puzzles, dispatcher correctly distributes layers. --- Source/functions/solve/puzzleExtension.cpp | 2 +- Source/functions/solve/structure.cpp | 9 ++++++--- Source/main.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/functions/solve/puzzleExtension.cpp b/Source/functions/solve/puzzleExtension.cpp index 5906441..e46999c 100644 --- a/Source/functions/solve/puzzleExtension.cpp +++ b/Source/functions/solve/puzzleExtension.cpp @@ -32,7 +32,7 @@ void Puzzle::putIntoBox() for(int j=0;jgetSizeAsCoor().row;j++) { - tmpPart.m_a1=this->a1.m_constraintMatrix[i][j]; + tmpPart.m_a1=this->a1.m_constraintMatrix[i+1][j+1]; //sets part id tmpPart.SetPartID(id++); // adds all 4 rotations to Box diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index 71e521e..8a21627 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -9,7 +9,8 @@ bool next(vector& log,Puzzle& puzzleMat) { //last log element is set, create new log element or log not yet started if(!(log.size()) || log.back().isSet()) - if((puzzleMat.allSet())) return false; //puzzle solved + if((puzzleMat.allSet())) + return false; //puzzle solved else createNextLogElement(log,puzzleMat); //last log element is empty, backtrack @@ -116,10 +117,12 @@ bool backtrack(vector& log, Puzzle& puzzleMat) return false; } puzzleMat.combinedQualityVector.clear(); //remove all data from temp quality save - //if more pieces possible, take next piece + //if more pieces possible, tset piece as not logged if((log.back().PieceCollector.size())>1) { - puzzleMat.p_myBox.push_back(log.back().PieceCollector.begin()->second); + for(int i=0;iGetPartID()==log.back().PieceCollector.begin()->second->GetPartID())//sets all with partid + puzzleMat.p_myBox[i]->set=false; log.back().PieceCollector.erase(log.back().PieceCollector.begin()); if(log.back().PieceCollector.size()==1) diff --git a/Source/main.cpp b/Source/main.cpp index 661a56a..3472ac5 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -5,7 +5,7 @@ int LogEntry::randomed(0); int main() { - unsigned int cols=6,rows=8; + unsigned int cols=9,rows=8; vector log; Puzzle puzzleMat(cols, rows);