From ccf26f8d8a18de737a7724a8b4f85dd39f2957f8 Mon Sep 17 00:00:00 2001 From: Raphael Maenle <17550607+g-spacewhale@users.noreply.github.com> Date: Tue, 12 Dec 2017 11:42:31 +0100 Subject: [PATCH] added empty functions for calls in structure.cpp check if set or next abstraction is now done at the very beginning! --- Source/functions/solve/structure.cpp | 73 +++++++++++----------------- 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index e9e4b04..a9ccab2 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -5,50 +5,21 @@ void status(vector& log, vector& p_Box, Puzzle& puzzleMa bool next(vector& log, vector& p_Box, Puzzle& puzzleMat) { - //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 + //last log element is set, create new log element or log not yet started if(!(log.size()) || log.back().isSet()) { - if(!(p_Box.size())) - { - cout << "box done" << endl; - return 0; - } - log.push_back(LogEntry()); - log.back().myCoor = calculateNextCoor(log, p_Box, puzzleMat); - solve(log, p_Box,puzzleMat); + if(!(p_Box.size())) return 0; //puzzle solved + else createNextLogElement(); } - //last log element is empty, backtrack - else if(!(log.back().PieceCollector.size())) - backtrack(log,p_Box,puzzleMat); - + else if(!(log.back().PieceCollector.size())) backtrack(log,p_Box,puzzleMat); //case last log element has multiple entries else if(log.back().PieceCollector.size() > 1) { - //is not yet max abstracted - if(log.back().abstractionLevel < MAX_ABSTRAX) - { - log.back().advance(); - solve(log,p_Box,puzzleMat); - } - //no more layers, pick first - else - { - log.back().advanceRandomed(); - setsolution(log,p_Box,puzzleMat); - } + //moreLayers is 0, setbest is 1 + if(SetBestorMoreLayers()) setsolution(log,p_Box,puzzleMat); + else solve(log,p_Box,puzzleMat); } - //case last log exactly one solution else if(log.back().PieceCollector.size() == 1) { @@ -68,6 +39,15 @@ bool next(vector& log, vector& p_Box, Puzzle& puzzleMat) return 1; } +void createNextLogElement(vector& log, vector& 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& log, vector& p_Box, Puzzle& puzzleMat) { //level 1: @@ -90,24 +70,24 @@ coor calculateNextCoor(vector& log, vector& p_Box, Puzzl void solve(vector& log, vector& p_Box, Puzzle& puzzleMat) { + getNextHighestLayerworth(puzzleMat); //sets in abstractionLevel //status(log,p_Box,puzzleMat); switch(log.back().abstractionLevel) { - //abstraction layer = 0 - //go to abstraction layer 0 solver - case 0: - abstractionlayer0solver(log,p_Box,puzzleMat); + case 0: abstractionlayer0solver(log,p_Box,puzzleMat); break; - - //abstraction layer = 1 - //go to abstraction layer 1 solver - case 1: - abstractionlayer1solver(log,p_Box,puzzleMat); + case 1: abstractionlayer1solver(log,p_Box,puzzleMat); break; default: break; } + + capLogElements(log); + calculateWorth(log); + calculateTrueDestructionPower(log,puzzleMat); + calculateNewCombinedProbablility(log); + } void abstractionlayer0solver(vector& log, vector& p_Box, Puzzle& puzzleMat) @@ -138,6 +118,9 @@ void abstractionlayer1solver(vector& log, vector& p_Box, void setsolution(vector& log, vector& 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 for(int i=0;i