added empty functions for calls in structure.cpp

check if set or next abstraction is now done at the very beginning!
This commit is contained in:
Raphael Maenle 2017-12-12 11:42:31 +01:00
parent bf3b103251
commit ccf26f8d8a

View File

@ -5,50 +5,21 @@ 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)
{ {
//log not yet started //last log element is set, create new log element or log not yet started
/*
if(!(log.size()))
{
log.push_back(LogEntry());
log.back().myCoor = calculateNextCoor(log, p_Box, puzzleMat);
solve(log, p_Box,puzzleMat);
}
*/
//last log element is set, create new log element
if(!(log.size()) || log.back().isSet()) if(!(log.size()) || log.back().isSet())
{ {
if(!(p_Box.size())) if(!(p_Box.size())) return 0; //puzzle solved
{ else createNextLogElement();
cout << "box done" << endl;
return 0;
} }
log.push_back(LogEntry());
log.back().myCoor = calculateNextCoor(log, p_Box, puzzleMat);
solve(log, p_Box,puzzleMat);
}
//last log element is empty, backtrack //last log element is empty, backtrack
else if(!(log.back().PieceCollector.size())) else if(!(log.back().PieceCollector.size())) backtrack(log,p_Box,puzzleMat);
backtrack(log,p_Box,puzzleMat);
//case last log element has multiple entries //case last log element has multiple entries
else if(log.back().PieceCollector.size() > 1) else if(log.back().PieceCollector.size() > 1)
{ {
//is not yet max abstracted //moreLayers is 0, setbest is 1
if(log.back().abstractionLevel < MAX_ABSTRAX) if(SetBestorMoreLayers()) setsolution(log,p_Box,puzzleMat);
{ else solve(log,p_Box,puzzleMat);
log.back().advance();
solve(log,p_Box,puzzleMat);
} }
//no more layers, pick first
else
{
log.back().advanceRandomed();
setsolution(log,p_Box,puzzleMat);
}
}
//case last log exactly one solution //case last log exactly one solution
else if(log.back().PieceCollector.size() == 1) else if(log.back().PieceCollector.size() == 1)
{ {
@ -68,6 +39,15 @@ bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
return 1; return 1;
} }
void createNextLogElement(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{
log.push_back(LogEntry());
log.back().myCoor = calculateNextCoor(log, p_Box, puzzleMat);
getLayerDestructionPowerfromSurrounding();
solve(log, p_Box,puzzleMat);
}
coor calculateNextCoor(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) coor calculateNextCoor(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
//level 1: //level 1:
@ -90,24 +70,24 @@ coor calculateNextCoor(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzl
void solve(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) void solve(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
getNextHighestLayerworth(puzzleMat); //sets in abstractionLevel
//status(log,p_Box,puzzleMat); //status(log,p_Box,puzzleMat);
switch(log.back().abstractionLevel) switch(log.back().abstractionLevel)
{ {
//abstraction layer = 0 case 0: abstractionlayer0solver(log,p_Box,puzzleMat);
//go to abstraction layer 0 solver
case 0:
abstractionlayer0solver(log,p_Box,puzzleMat);
break; break;
case 1: abstractionlayer1solver(log,p_Box,puzzleMat);
//abstraction layer = 1
//go to abstraction layer 1 solver
case 1:
abstractionlayer1solver(log,p_Box,puzzleMat);
break; break;
default: default:
break; break;
} }
capLogElements(log);
calculateWorth(log);
calculateTrueDestructionPower(log,puzzleMat);
calculateNewCombinedProbablility(log);
} }
void abstractionlayer0solver(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) void abstractionlayer0solver(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
@ -138,6 +118,9 @@ void abstractionlayer1solver(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box,
void setsolution(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) void setsolution(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
//advance number of randomed part count
if(log.back().PieceCollector.size()>1) log.back().advanceRandomed();
//remove first element in last logelement from box //remove first element in last logelement from box
for(int i=0;i<p_Box.size();) for(int i=0;i<p_Box.size();)
if(p_Box[i]==log.back().PieceCollector[0]) if(p_Box[i]==log.back().PieceCollector[0])