2017-12-21 12:20:57 +01:00
|
|
|
//
|
|
|
|
// Created by mpapa on 05.12.2017.
|
|
|
|
//
|
2017-12-21 12:43:31 +01:00
|
|
|
#pragma once
|
2017-12-06 16:25:13 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
2017-11-18 08:36:50 +01:00
|
|
|
|
2017-12-21 12:20:57 +01:00
|
|
|
#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1.h"
|
|
|
|
#include "../functions/AbstractionLayers/DestructionPower/DestructionPower.h"
|
2017-12-20 22:58:00 +01:00
|
|
|
|
2017-11-18 08:36:50 +01:00
|
|
|
|
2017-12-21 12:20:57 +01:00
|
|
|
using namespace std;
|
2017-12-06 20:56:01 +01:00
|
|
|
|
2017-11-18 08:36:50 +01:00
|
|
|
class LogEntry
|
|
|
|
{
|
|
|
|
public:
|
2017-12-20 18:23:39 +01:00
|
|
|
map<Part*, float> PieceCollector;
|
2017-11-18 08:36:50 +01:00
|
|
|
int abstractionLevel;
|
2017-11-21 10:31:48 +01:00
|
|
|
coor myCoor;
|
2017-11-18 22:48:40 +01:00
|
|
|
|
|
|
|
void advance(){abstractionLevel++;}
|
2017-11-19 22:53:00 +01:00
|
|
|
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;
|
2017-12-21 12:43:31 +01:00
|
|
|
set=false;
|
2017-11-18 08:36:50 +01:00
|
|
|
}
|
|
|
|
private:
|
2017-11-19 22:53:00 +01:00
|
|
|
bool set;
|
|
|
|
static int randomed;
|
2017-11-18 08:36:50 +01:00
|
|
|
};
|
|
|
|
|
2017-12-21 12:20:57 +01:00
|
|
|
class Puzzle
|
|
|
|
{
|
|
|
|
public:
|
2017-12-22 23:00:31 +01:00
|
|
|
|
2017-12-29 14:33:22 +01:00
|
|
|
Puzzle(unsigned int newcols,unsigned int newrows):rows(newrows),cols(newcols) {}
|
|
|
|
|
|
|
|
bool PreProcessing()
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2017-12-29 14:33:22 +01:00
|
|
|
return a1.PreProcessing({rows,cols}, nullptr);
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
2017-12-21 12:20:57 +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;
|
2017-12-21 12:20:57 +01:00
|
|
|
|
|
|
|
void removeConstrains(coor removeCoordinates);
|
|
|
|
void printPuzzle();
|
2017-12-23 10:11:07 +01:00
|
|
|
void printBox();
|
2017-12-21 12:20:57 +01:00
|
|
|
|
2017-12-21 13:07:01 +01:00
|
|
|
void createRandomBox(){createRandomPuzzle();putIntoBox();shuffle();createp_box();}
|
2017-12-21 12:43:31 +01:00
|
|
|
void createRandomPuzzle();
|
2017-12-21 12:20:57 +01:00
|
|
|
void putIntoBox();
|
|
|
|
void shuffle();
|
2017-12-21 13:07:01 +01:00
|
|
|
void createp_box();
|
2017-12-21 12:20:57 +01:00
|
|
|
|
|
|
|
vector<Part> myBox;
|
|
|
|
vector<Part*> p_myBox;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
unsigned int rows;
|
|
|
|
unsigned int cols;
|
|
|
|
};
|
|
|
|
|
2017-12-20 22:10:08 +01:00
|
|
|
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);
|
2017-12-21 12:20:57 +01:00
|
|
|
bool backtrack(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
2017-11-19 17:52:02 +01:00
|
|
|
|
2017-12-20 22:09:41 +01:00
|
|
|
void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
2017-11-19 17:52:02 +01:00
|
|
|
|