From bd07d291db5594ce87d7f8284438b9ad9718aa1e Mon Sep 17 00:00:00 2001 From: Raphael Maenle <17550607+g-spacewhale@users.noreply.github.com> Date: Thu, 21 Dec 2017 12:43:31 +0100 Subject: [PATCH] started random algorithm. problem with funciton separation between properties and layer --- .../DestructionPower/DestructionPower.h | 5 +---- .../DestructionPower_Properties.h | 5 +---- Source/functions/solve/classExtension.cpp | 14 ------------- Source/functions/solve/puzzleExtension.cpp | 20 ++++++++++++++++++- Source/functions/solve/structure.cpp | 3 +-- Source/header.h | 6 +----- Source/header/input.h | 15 ++++++-------- Source/header/solve.h | 14 ++++--------- Source/main.cpp | 1 + 9 files changed, 34 insertions(+), 49 deletions(-) diff --git a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h index 0f70dcd..eb2bd44 100644 --- a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h +++ b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h @@ -2,8 +2,7 @@ // Created by mpapa on 05.12.2017. // -#ifndef SOURCE_DESTRUCTIONPOWER_H -#define SOURCE_DESTRUCTIONPOWER_H +#pragma once #define DESTRUCTION_COUNT 1 @@ -27,5 +26,3 @@ public: private: }; - -#endif //SOURCE_DESTRUCTIONPOWER_H diff --git a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h index 2a8f0a0..bbdedca 100644 --- a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h +++ b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h @@ -14,10 +14,7 @@ class DestructionPower_Properties { public: explicit DestructionPower_Properties(); - map getSpeedTable() - { - return SpeedTable; - } + map getSpeedTable() {return SpeedTable;} void setSpeedTable(); private: diff --git a/Source/functions/solve/classExtension.cpp b/Source/functions/solve/classExtension.cpp index 03f9dc4..0dae9f2 100755 --- a/Source/functions/solve/classExtension.cpp +++ b/Source/functions/solve/classExtension.cpp @@ -37,18 +37,4 @@ void createRandomAbstraction2() i++; j=0; } -} - -//shuffles around a box, randomizing pieces and orientation -vector randomBox::shuffle() -{ - random_shuffle(Box.begin(),Box.end()); - for (auto &i:Box) - { - i.shift(rand()%4); - i.resetShift(); - } - - numerateBox(Box); - return Box; } \ No newline at end of file diff --git a/Source/functions/solve/puzzleExtension.cpp b/Source/functions/solve/puzzleExtension.cpp index 58427be..d266b6e 100644 --- a/Source/functions/solve/puzzleExtension.cpp +++ b/Source/functions/solve/puzzleExtension.cpp @@ -7,5 +7,23 @@ void Puzzle::printPuzzle() {} void Puzzle::putIntoBox() {}//puts a puzzlepiece back into its box -void Puzzle::shuffle() {}//shuffles the existing box in Puzzle + +//shuffles the existing box in Puzzle +void Puzzle::shuffle() +{ + random_shuffle(myBox.begin(),myBox.end()); + for (auto &i:myBox) + { + //i.myLayers->m_test1 + //shift(rand()%4,i); + //i.resetShift(); + } +} + + void Puzzle::removeConstrains(coor removeCoordinates) {}//deletes all constraints from all abstractionlayers + +void Puzzle::createRandomPuzzle() +{ + a1->CreateRandomPuzzle(); +} \ No newline at end of file diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index 8a10792..fd66d7b 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -40,7 +40,7 @@ bool next(vector& log, vector& p_Box,Puzzle& puzzleMat) void createNextLogElement(vector& log, vector& p_Box, Puzzle& puzzleMat) { - log.emplace_back(LogEntry()); + log.emplace_back(LogEntry(coor(0, 0))); log.back().myCoor = calculateNextCoor(log, p_Box,puzzleMat); //getLayerDestructionPowerfromSurrounding(); solve(log, p_Box,puzzleMat); @@ -62,7 +62,6 @@ coor calculateNextCoor(vector& log, vector& p_Box, Puzzle& puzz if(m #include #include @@ -13,5 +11,3 @@ using namespace std; #include "header/input.h" #include "header/solve.h" - -#endif //HEADER_H \ No newline at end of file diff --git a/Source/header/input.h b/Source/header/input.h index 340b42a..a563c6f 100755 --- a/Source/header/input.h +++ b/Source/header/input.h @@ -2,11 +2,9 @@ // Created by mpapa on 05.12.2017. // -#ifndef SOURCE_INPUT_H -#define SOURCE_INPUT_H +#pragma once - -#include +#include #include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h" #include "../functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h" @@ -16,8 +14,9 @@ class LayerContainer; class Part { public: - Part() : m_partID(0) {} - ~Part() {} + Part() : m_partID(0), m_numOfRotations(0) + {} + ~Part() = default; int32_t GetPartID () const { @@ -50,8 +49,6 @@ class coor { public: unsigned int col, row; - coor(unsigned int newcol=-1,unsigned int newrow=-1): col(newcol), row(newrow) + coor (unsigned int newcol,unsigned int newrow): col(newcol), row(newrow) {} }; - -#endif //SOURCE_INPUT_H diff --git a/Source/header/solve.h b/Source/header/solve.h index 037820b..430d945 100755 --- a/Source/header/solve.h +++ b/Source/header/solve.h @@ -1,10 +1,7 @@ // // Created by mpapa on 05.12.2017. // - -#ifndef SOURCE_SOLVE_H -#define SOURCE_SOLVE_H - +#pragma once #include #include #include @@ -30,11 +27,9 @@ public: void decreaseRandomed() { randomed--;} int hasRandomed(){return randomed;} - LogEntry() - { - myCoor = coor(0,0); + LogEntry(coor newCoor = coor(0,0)): myCoor(newCoor){ abstractionLevel=0; - set=0; + set=false; } private: bool set; @@ -56,7 +51,7 @@ public: void printPuzzle(); void createRandomBox(){createRandomPuzzle();putIntoBox();shuffle();} - void createRandomPuzzle(){a1->CreateRandomPuzzle();} + void createRandomPuzzle(); void putIntoBox(); void shuffle(); @@ -85,4 +80,3 @@ bool backtrack(vector& log, vector& p_Box, Puzzle& puzzleMat); void createNextLogElement(vector& log, vector& p_Box, Puzzle& puzzleMat); -#endif //SOURCE_SOLVE_H diff --git a/Source/main.cpp b/Source/main.cpp index d80bc1c..c71d606 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -16,6 +16,7 @@ int main() vector p_myFirstBox; Puzzle puzzleMat(cols, rows); + puzzleMat.createRandomBox(); //vector> ab1class = abstractionLayer1classify(log, p_myFirstBox,puzzleMat); while(next(log, puzzleMat.p_myBox,puzzleMat));