started random algorithm. problem with funciton separation between properties and layer

This commit is contained in:
Raphael Maenle 2017-12-21 12:43:31 +01:00
parent dd9f8f3250
commit bd07d291db
9 changed files with 34 additions and 49 deletions

View File

@ -2,8 +2,7 @@
// Created by mpapa on 05.12.2017. // Created by mpapa on 05.12.2017.
// //
#ifndef SOURCE_DESTRUCTIONPOWER_H #pragma once
#define SOURCE_DESTRUCTIONPOWER_H
#define DESTRUCTION_COUNT 1 #define DESTRUCTION_COUNT 1
@ -27,5 +26,3 @@ public:
private: private:
}; };
#endif //SOURCE_DESTRUCTIONPOWER_H

View File

@ -14,10 +14,7 @@ class DestructionPower_Properties
{ {
public: public:
explicit DestructionPower_Properties(); explicit DestructionPower_Properties();
map<int,float> getSpeedTable() map<int,float> getSpeedTable() {return SpeedTable;}
{
return SpeedTable;
}
void setSpeedTable(); void setSpeedTable();
private: private:

View File

@ -38,17 +38,3 @@ void createRandomAbstraction2()
j=0; j=0;
} }
} }
//shuffles around a box, randomizing pieces and orientation
vector<Part> randomBox::shuffle()
{
random_shuffle(Box.begin(),Box.end());
for (auto &i:Box)
{
i.shift(rand()%4);
i.resetShift();
}
numerateBox(Box);
return Box;
}

View File

@ -7,5 +7,23 @@
void Puzzle::printPuzzle() {} void Puzzle::printPuzzle() {}
void Puzzle::putIntoBox() {}//puts a puzzlepiece back into its box 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::removeConstrains(coor removeCoordinates) {}//deletes all constraints from all abstractionlayers
void Puzzle::createRandomPuzzle()
{
a1->CreateRandomPuzzle();
}

View File

@ -40,7 +40,7 @@ bool next(vector<LogEntry>& log, vector<Part*>& p_Box,Puzzle& puzzleMat)
void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat) void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
{ {
log.emplace_back(LogEntry()); log.emplace_back(LogEntry(coor(0, 0)));
log.back().myCoor = calculateNextCoor(log, p_Box,puzzleMat); log.back().myCoor = calculateNextCoor(log, p_Box,puzzleMat);
//getLayerDestructionPowerfromSurrounding(); //getLayerDestructionPowerfromSurrounding();
solve(log, p_Box,puzzleMat); solve(log, p_Box,puzzleMat);
@ -62,7 +62,6 @@ coor calculateNextCoor(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzz
if(m<puzzleMat.getSizeAsCoor().col-1) m++; if(m<puzzleMat.getSizeAsCoor().col-1) m++;
else if(n<puzzleMat.getSizeAsCoor().row-1){ m=0; n++;} else if(n<puzzleMat.getSizeAsCoor().row-1){ m=0; n++;}
else return {};
return {m,n}; return {m,n};
//return nextCoor; //return nextCoor;
} }

View File

@ -1,6 +1,4 @@
#ifndef HEADER_H #pragma once
#define HEADER_H
#include <iostream> #include <iostream>
#include <bitset> #include <bitset>
#include <cstdlib> #include <cstdlib>
@ -13,5 +11,3 @@ using namespace std;
#include "header/input.h" #include "header/input.h"
#include "header/solve.h" #include "header/solve.h"
#endif //HEADER_H

View File

@ -2,11 +2,9 @@
// Created by mpapa on 05.12.2017. // Created by mpapa on 05.12.2017.
// //
#ifndef SOURCE_INPUT_H #pragma once
#define SOURCE_INPUT_H
#include <cstdint>
#include <stdint.h>
#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h" #include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h"
#include "../functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h" #include "../functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h"
@ -16,8 +14,9 @@ class LayerContainer;
class Part class Part
{ {
public: public:
Part() : m_partID(0) {} Part() : m_partID(0), m_numOfRotations(0)
~Part() {} {}
~Part() = default;
int32_t GetPartID () const int32_t GetPartID () const
{ {
@ -50,8 +49,6 @@ class coor
{ {
public: public:
unsigned int col, row; 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

View File

@ -1,10 +1,7 @@
// //
// Created by mpapa on 05.12.2017. // Created by mpapa on 05.12.2017.
// //
#pragma once
#ifndef SOURCE_SOLVE_H
#define SOURCE_SOLVE_H
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <opencv2/highgui/highgui.hpp> #include <opencv2/highgui/highgui.hpp>
@ -30,11 +27,9 @@ public:
void decreaseRandomed() { randomed--;} void decreaseRandomed() { randomed--;}
int hasRandomed(){return randomed;} int hasRandomed(){return randomed;}
LogEntry() LogEntry(coor newCoor = coor(0,0)): myCoor(newCoor){
{
myCoor = coor(0,0);
abstractionLevel=0; abstractionLevel=0;
set=0; set=false;
} }
private: private:
bool set; bool set;
@ -56,7 +51,7 @@ public:
void printPuzzle(); void printPuzzle();
void createRandomBox(){createRandomPuzzle();putIntoBox();shuffle();} void createRandomBox(){createRandomPuzzle();putIntoBox();shuffle();}
void createRandomPuzzle(){a1->CreateRandomPuzzle();} void createRandomPuzzle();
void putIntoBox(); void putIntoBox();
void shuffle(); void shuffle();
@ -85,4 +80,3 @@ bool backtrack(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat); void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
#endif //SOURCE_SOLVE_H

View File

@ -16,6 +16,7 @@ int main()
vector<Part*> p_myFirstBox; vector<Part*> p_myFirstBox;
Puzzle puzzleMat(cols, rows); Puzzle puzzleMat(cols, rows);
puzzleMat.createRandomBox();
//vector<vector<PuzzlePiece*>> ab1class = abstractionLayer1classify(log, p_myFirstBox,puzzleMat); //vector<vector<PuzzlePiece*>> ab1class = abstractionLayer1classify(log, p_myFirstBox,puzzleMat);
while(next(log, puzzleMat.p_myBox,puzzleMat)); while(next(log, puzzleMat.p_myBox,puzzleMat));