changed review and log

This commit is contained in:
g-spacewhale 2017-11-21 10:31:48 +01:00
parent 772a1d815a
commit 665ad108d4
2 changed files with 19 additions and 8 deletions

View File

@ -3,9 +3,7 @@ void status(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMa
bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
//status(log,p_Box,puzzleMat); //status(log,p_Box,puzzleMat);
//log not yet started //log not yet started
if(!(log.size())) if(!(log.size()))
{ {
@ -15,7 +13,6 @@ bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
solve(log, p_Box,puzzleMat); solve(log, p_Box,puzzleMat);
} }
//last log element is set, create new log element //last log element is set, create new log element
else if(log.back().isSet()) else if(log.back().isSet())
{ {
@ -79,8 +76,12 @@ bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
} }
} }
//cout << "next" << endl; //cout << "next" << endl;
if(log.back().myCoor.n>36)
return 1; {
cout << "m: " << log.back().myCoor.m << " n: " << log.back().myCoor.n << endl;
status(log,p_Box,puzzleMat);
}
return 1;
} }
@ -198,6 +199,8 @@ bool backtrack(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzl
{ {
//cout << "one" << endl; //cout << "one" << endl;
p_Box.push_back(log.back().PieceCollector[0]); p_Box.push_back(log.back().PieceCollector[0]);
//shuffleup
random_shuffle(p_Box.begin(),p_Box.end());
puzzleMat.removePiece(log.back().myCoor.m, log.back().myCoor.n); puzzleMat.removePiece(log.back().myCoor.m, log.back().myCoor.n);
log.pop_back(); log.pop_back();
//cout << "removed" << endl; //cout << "removed" << endl;
@ -211,6 +214,8 @@ bool backtrack(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzl
{ {
//cout << "multiple" << endl; //cout << "multiple" << endl;
p_Box.push_back(log.back().PieceCollector[0]); p_Box.push_back(log.back().PieceCollector[0]);
//shuffleup
random_shuffle(p_Box.begin(),p_Box.end());
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)
@ -241,8 +246,8 @@ void status(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMa
else else
cout << "isset: 0" << endl; cout << "isset: 0" << endl;
cout << "Abstraction: " << log[i].abstractionLevel << endl; //cout << "Abstraction: " << log[i].abstractionLevel << endl;
cout << "m: " << log[i].myCoor.m << " n: " << log[i].myCoor.n << endl; //cout << "m: " << log[i].myCoor.m << " n: " << log[i].myCoor.n << endl;
/*for(int j=0;j<log[i].PieceCollector.size();j++) /*for(int j=0;j<log[i].PieceCollector.size();j++)
{ {
(*(log[i].PieceCollector[j])).printPiece(); (*(log[i].PieceCollector[j])).printPiece();
@ -253,6 +258,11 @@ void status(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMa
cout << endl; cout << endl;
cout << "Box:" << endl; cout << "Box:" << endl;
cout << "size: " << p_Box.size() << endl; cout << "size: " << p_Box.size() << endl;
for(vector<PuzzlePiece*>::iterator i = p_Box.begin();i!=p_Box.end();i++)
{
(*(*i)).printPiece();
cout << endl;
}
cout << "Puzzle:" << endl; cout << "Puzzle:" << endl;
puzzleMat.printPuzzle(); puzzleMat.printPuzzle();

View File

@ -136,7 +136,7 @@ class LogEntry
public: public:
vector<PuzzlePiece*> PieceCollector; vector<PuzzlePiece*> PieceCollector;
int abstractionLevel; int abstractionLevel;
coor myCoor = coor(); coor myCoor;
void advance(){abstractionLevel++;} void advance(){abstractionLevel++;}
void Set(){set=1;} void Set(){set=1;}
@ -147,6 +147,7 @@ public:
LogEntry() LogEntry()
{ {
myCoor = coor();
abstractionLevel=0; abstractionLevel=0;
set=0; set=0;
} }