diff --git a/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h b/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h index f14d362..4d72b50 100644 --- a/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h +++ b/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h @@ -1,13 +1,12 @@ #ifndef SOURCE_ABSTRAKTIONLAYER_BASE_H #define SOURCE_ABSTRAKTIONLAYER_BASE_H -#include #include #include "../../header/input.h" using namespace std; -typedef map qualityVector; +typedef vector> qualityVector; /* * Die Logik mit der Template-Basisklasse und den abgeleiteten Layern kam mit der Idee, dass die Layer diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp index b205b01..e44d2cd 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp @@ -46,7 +46,7 @@ bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, quali { for(auto it = qVector.begin(); it != qVector.end(); it++) { - if(PlaceOfPartGood(constraintCoordinate, it->first->m_a1.m_connections)) + if(PlaceOfPartGood(constraintCoordinate, it->second->m_a1.m_connections)) continue; qVector.erase(it++); } diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index 8ea726f..08b555a 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -99,7 +99,7 @@ void setsolution(vector& log, vector& p_Box, Puzzle& puzzleMat) //remove first element in last logelement from box for(int i=0;ifirst)//mach ich das richtig so?! + if(p_Box[i]==log.back().PieceCollector.begin()->second)//mach ich das richtig so?! p_Box.erase(p_Box.begin()+i); else i++; @@ -113,7 +113,7 @@ bool backtrack(vector& log, vector& p_Box, Puzzle& puzzleMat) //if more pieces possible, take next piece if((log.back().PieceCollector.size())>1) { - p_Box.push_back(log.back().PieceCollector.begin()->first); + p_Box.push_back(log.back().PieceCollector.begin()->second); log.back().PieceCollector.erase(log.back().PieceCollector.begin()); if(log.back().PieceCollector.size()==1) @@ -128,7 +128,7 @@ bool backtrack(vector& log, vector& p_Box, Puzzle& puzzleMat) { puzzleMat.removeConstrains(log.back().myCoor); //this should remove constraints from all layers if((log.back().PieceCollector.size())) - p_Box.emplace_back(log.back().PieceCollector.begin()->first); + p_Box.emplace_back(log.back().PieceCollector.begin()->second); log.pop_back(); backtrack(log,p_Box,puzzleMat); } @@ -182,9 +182,9 @@ float capLogElements(vector& log) vectorsizeBefore = log.back().PieceCollector.size(); sort(log); // Sort the vector after probabilities - std::map::const_iterator idxcut =log.back().PieceCollector.begin(); + qualityVector::const_iterator idxcut =log.back().PieceCollector.begin(); for(;idxcut !=log.back().PieceCollector.end();idxcut++) - if(idxcut->second < limit) + if(idxcut->first < limit) break; @@ -200,7 +200,7 @@ float capLogElements(vector& log) newidxcut = idxcut; } } - cut(log,newidxcut->first); + cut(log,newidxcut->second); vectorsizeAfter = log.back().PieceCollector.size(); @@ -218,14 +218,32 @@ void sort(vector& log) //the monkey desperately tried to hold on to the flying dorm room. } +qualityVector::iterator FindPartInLog(vector& log, Part* wishedPartPointer) +{ + qualityVector::iterator partOnPositionIterator = log.back().PieceCollector.begin(); + + while (partOnPositionIterator != log.back().PieceCollector.end()) + { + if(partOnPositionIterator.base()->second == wishedPartPointer) + { + break; + } + else + { + partOnPositionIterator++; + } + } + + return partOnPositionIterator; +} + void cut(vector& log, Part* cutID) { - auto it = log.back().PieceCollector.find(cutID)++; + auto it = FindPartInLog(log, cutID); while(it != log.back().PieceCollector.end()) log.back().PieceCollector.erase(it++); } - //partdavid bool setBestOrMoreLayers(vector& log) { @@ -236,11 +254,11 @@ bool setBestOrMoreLayers(vector& log) for(auto it:log.back().PieceCollector) { // check Probability of current Puzzle Piece in this vector - if (it.second >= 0.90) // 0.90 as threshold + if (it.first >= 0.90) // 0.90 as threshold countBest++; else - if (it.second > tempBest) - tempBest = it.second; + if (it.first > tempBest) + tempBest = it.first; } // return true if only one piece is left diff --git a/Source/header/solve.h b/Source/header/solve.h index 9b9fa2f..f6c7a4c 100755 --- a/Source/header/solve.h +++ b/Source/header/solve.h @@ -10,13 +10,12 @@ #include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1.h" #include "../functions/AbstractionLayers/DestructionPower/DestructionPower.h" - using namespace std; class LogEntry { public: - map PieceCollector; + qualityVector PieceCollector; int abstractionLevel; coor myCoor;