PuzzleSolver/Source/header/solve.h

87 lines
2.2 KiB
C
Raw Normal View History

//
// Created by mpapa on 05.12.2017.
//
#pragma once
#include <vector>
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
2017-11-18 08:36:50 +01:00
#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1.h"
#include "../functions/AbstractionLayers/DestructionPower/DestructionPower.h"
using namespace std;
2017-11-18 08:36:50 +01:00
class LogEntry
{
public:
qualityVector PieceCollector;
2017-11-18 08:36:50 +01:00
int abstractionLevel;
2017-11-21 10:31:48 +01:00
coor myCoor;
void advance(){abstractionLevel++;}
void Set(){set=1;}
bool isSet(){return set;}
void advanceRandomed() { randomed++;}
void decreaseRandomed() { randomed--;}
int hasRandomed(){return randomed;}
2017-11-18 08:36:50 +01:00
2017-12-22 22:55:55 +01:00
explicit LogEntry(coor newCoor = coor(0,0)): myCoor(newCoor){
abstractionLevel=-1;
set=false;
2017-11-18 08:36:50 +01:00
}
private:
bool set;
static int randomed;
2017-11-18 08:36:50 +01:00
};
class Puzzle
{
public:
Puzzle(unsigned int newcols,unsigned int newrows):rows(newrows),cols(newcols) {}
bool PreProcessing()
2017-12-22 22:55:55 +01:00
{
createBox(); createp_box();
dp.PreProcessing({rows,cols}, nullptr);
a1.PreProcessing({rows,cols}, &p_myBox);
return true;
2017-12-22 22:55:55 +01:00
}
coor getSizeAsCoor() {return {cols,rows};}
2017-12-22 23:09:23 +01:00
DestructionPower dp;
2017-12-22 22:47:14 +01:00
AbstractionLayer_1 a1;
void removeConstrains(coor removeCoordinates);
void printPuzzle();
void printBox();
void createRandomBox(){createRandomPuzzle();putIntoBox();shuffle();createp_box();}
void createRandomPuzzle();
void putIntoBox();
void shuffle();
void createBox();
void createp_box();
vector<Part> myBox;
vector<Part*> p_myBox;
qualityVector combinedQualityVector;
private:
unsigned int rows;
unsigned int cols;
};
bool next(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
coor calculateNextCoor(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
void solve(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
void setsolution(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
bool backtrack(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);