dispatcher-a1 now functional

a1 Solver finds solutions for puzzles, dispatcher correctly distributes layers.
This commit is contained in:
Raphael Maenle 2018-01-08 18:33:30 +01:00
parent 6754873cfd
commit c0f0417d3b
3 changed files with 8 additions and 5 deletions

View File

@ -32,7 +32,7 @@ void Puzzle::putIntoBox()
for(int j=0;j<this->getSizeAsCoor().row;j++) for(int j=0;j<this->getSizeAsCoor().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 //sets part id
tmpPart.SetPartID(id++); tmpPart.SetPartID(id++);
// adds all 4 rotations to Box // adds all 4 rotations to Box

View File

@ -9,7 +9,8 @@ bool next(vector<LogEntry>& log,Puzzle& puzzleMat)
{ {
//last log element is set, create new log element or log not yet started //last log element is set, create new log element or log not yet started
if(!(log.size()) || log.back().isSet()) if(!(log.size()) || log.back().isSet())
if((puzzleMat.allSet())) return false; //puzzle solved if((puzzleMat.allSet()))
return false; //puzzle solved
else createNextLogElement(log,puzzleMat); else createNextLogElement(log,puzzleMat);
//last log element is empty, backtrack //last log element is empty, backtrack
@ -116,10 +117,12 @@ bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
return false; return false;
} }
puzzleMat.combinedQualityVector.clear(); //remove all data from temp quality save 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) if((log.back().PieceCollector.size())>1)
{ {
puzzleMat.p_myBox.push_back(log.back().PieceCollector.begin()->second); for(int i=0;i<puzzleMat.p_myBox.size();i++)
if(puzzleMat.p_myBox[i]->GetPartID()==log.back().PieceCollector.begin()->second->GetPartID())//sets all with partid
puzzleMat.p_myBox[i]->set=false;
log.back().PieceCollector.erase(log.back().PieceCollector.begin()); log.back().PieceCollector.erase(log.back().PieceCollector.begin());
if(log.back().PieceCollector.size()==1) if(log.back().PieceCollector.size()==1)

View File

@ -5,7 +5,7 @@ int LogEntry::randomed(0);
int main() int main()
{ {
unsigned int cols=6,rows=8; unsigned int cols=9,rows=8;
vector<LogEntry> log; vector<LogEntry> log;
Puzzle puzzleMat(cols, rows); Puzzle puzzleMat(cols, rows);