redid some of the includes and changed way statics are saved
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "../../header/solve.h"
|
||||
#include "../../header/input.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -19,7 +19,7 @@ typedef map<Part*, float> qualityVector;
|
||||
* @tparam T template parameter which should be the property class of the layer
|
||||
*/
|
||||
template<typename T>
|
||||
class AbstraktionLayer_Base
|
||||
class AbstractionLayer_Base
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -63,7 +63,7 @@ public:
|
||||
m_constraintMatrix = vector<vector<T>>(collumns, vector<T>(rows));
|
||||
}
|
||||
|
||||
vector<vector<T>> m_constraintMatrix; //!<-- Matrix where the constraints of the layer will be saved
|
||||
vector<vector<T>> m_constraintMatrix{}; //!<-- Matrix where the constraints of the layer will be saved
|
||||
};
|
||||
|
||||
|
||||
|
@ -3,7 +3,13 @@
|
||||
//
|
||||
|
||||
#include "DestructionPower.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
map<int,float> DestructionPower_Properties::SpeedTable =
|
||||
{
|
||||
{1,0.001}
|
||||
};
|
||||
|
||||
|
||||
void DestructionPower::PreProcessing(const vector<Part*>* partArray)
|
||||
{
|
||||
@ -31,14 +37,18 @@ void DestructionPower::DestructionOfSurrounding(const coor constraintCoordinate)
|
||||
if(constraintCoordinate.row > 0)
|
||||
{
|
||||
divisor++;
|
||||
newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row-1].m_destruction.DestructionArray[i];
|
||||
newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row-1].DestructionArray[i];
|
||||
}
|
||||
if(constraintCoordinate.col > 0)
|
||||
{
|
||||
divisor++;
|
||||
newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col-1][constraintCoordinate.row].m_destruction.DestructionArray[i];
|
||||
newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col-1][constraintCoordinate.row].DestructionArray[i];
|
||||
}
|
||||
if(divisor)
|
||||
newDestructionArray[i] /=divisor;
|
||||
}
|
||||
}
|
||||
DestructionPower_Properties::DestructionPower_Properties() {
|
||||
for(int i=0;i<sizeof(DestructionArray);i++)
|
||||
DestructionArray.emplace_back(DestructionPower_Properties::SpeedTable[i]*DESTRUCTION_INIT);
|
||||
}
|
@ -5,25 +5,25 @@
|
||||
#ifndef SOURCE_DESTRUCTIONPOWER_H
|
||||
#define SOURCE_DESTRUCTIONPOWER_H
|
||||
|
||||
#define DESTRUCTION_INIT 0.5
|
||||
#define DESTRUCTION_COUNT 1
|
||||
|
||||
#include "../AbstraktionLayer_Base.h"
|
||||
#include "DestructionPower_Properties.h"
|
||||
#include "../AbstraktionLayer_Base.h"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <bitset>
|
||||
#include <random>
|
||||
|
||||
class DestructionPower : public AbstraktionLayer_Base<DestructionPower_Properties>
|
||||
class DestructionPower : public AbstractionLayer_Base<DestructionPower_Properties>
|
||||
{
|
||||
public:
|
||||
void PreProcessing(const vector<Part*>* partArray);//override
|
||||
bool EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector);
|
||||
bool SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint);
|
||||
bool RemoveConstraintOnPosition(const coor constraintCoordinate);
|
||||
void PreProcessing(const vector<Part*>* partArray) override;
|
||||
bool EvaluateQuality (coor constraintCoordinate, qualityVector& qVector) override;
|
||||
bool SetConstraintOnPosition(coor constraintCoordinate, AbstractionLayer_1_Properties constraint);
|
||||
bool RemoveConstraintOnPosition(coor constraintCoordinate)override;
|
||||
|
||||
void DestructionOfSurrounding(const coor constraintCoordinate);
|
||||
void DestructionOfSurrounding(coor constraintCoordinate);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -1,47 +1,29 @@
|
||||
//
|
||||
// Created by mpapa on 05.12.2017.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#ifndef SOURCE_DESTRUCTIONPOWER_PROPERTIES_H
|
||||
#define SOURCE_DESTRUCTIONPOWER_PROPERTIES_H
|
||||
|
||||
#define DESTRUCTION_INIT 0.5
|
||||
#include <stdint.h>
|
||||
#include "DestructionPower.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class DestructionPower_Properties
|
||||
{
|
||||
public:
|
||||
DestructionPower_Properties()
|
||||
{
|
||||
for(int i=0;i<sizeof(DestructionArray);i++)
|
||||
DestructionArray[i]=(SpeedTable[i]*DESTRUCTION_INIT);
|
||||
|
||||
setSpeedTable();
|
||||
|
||||
}
|
||||
explicit DestructionPower_Properties();
|
||||
map<int,float> getSpeedTable()
|
||||
{
|
||||
return SpeedTable;
|
||||
}
|
||||
void setSpeedTable()
|
||||
{ SpeedTable=create_SpeedTable();}
|
||||
void setSpeedTable();
|
||||
|
||||
private:
|
||||
|
||||
static map<int,float> create_SpeedTable();
|
||||
static map<int,float> SpeedTable;
|
||||
|
||||
float DestructionArray[DESTRUCTION_COUNT];
|
||||
|
||||
vector<float> DestructionArray;
|
||||
friend class DestructionPower;
|
||||
|
||||
};
|
||||
|
||||
map<int,float> DestructionPower_Properties::create_SpeedTable()
|
||||
{
|
||||
map<int, float> m;
|
||||
m[1] = 0.001;
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif //SOURCE_DESTRUCTIONPOWER_PROPERTIES_H
|
||||
};
|
@ -3,6 +3,8 @@
|
||||
//
|
||||
|
||||
#include "AbstractionLayer_1.h"
|
||||
#include "../../../header.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void AbstractionLayer_1::PreProcessing(const vector<Part*>* partArray)
|
||||
@ -16,7 +18,7 @@ bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, quali
|
||||
{
|
||||
for(auto it = qVector.begin(); it != qVector.end(); it++)
|
||||
{
|
||||
if(PlaceOfPartGood(constraintCoordinate, it->first->m_test1.m_connections))
|
||||
if(PlaceOfPartGood(constraintCoordinate, it->first->myLayers->m_test1.m_connections))
|
||||
continue;
|
||||
qVector.erase(it++);
|
||||
}
|
||||
@ -90,7 +92,7 @@ qualityVector AbstractionLayer_1::returnInBox(vector<Part>& PuzzleBox)
|
||||
int i=0;
|
||||
for(int col=1;col<m_constraintMatrix.size()-1;col++)
|
||||
for(int row=1;row<m_constraintMatrix[col].size()-1;row++)
|
||||
PuzzleBox[i++].m_test1.m_connections=m_constraintMatrix[col][row].m_connections;
|
||||
PuzzleBox[i++].myLayers->m_test1.m_connections=m_constraintMatrix[col][row].m_connections;
|
||||
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ void AbstractionLayer_1::setEdgeZero()
|
||||
bool AbstractionLayer_1::PlaceOfPartGood(coor myCoor, uint8_t& myPart)
|
||||
{
|
||||
|
||||
uint8_t negativePart(0)=0b00000000;
|
||||
uint8_t negativePart=0b00000000;
|
||||
|
||||
negativePart or_eq (m_constraintMatrix[myCoor.col][myCoor.row+1].m_connections & 0b11000000);
|
||||
negativePart or_eq (m_constraintMatrix[myCoor.col-1][myCoor.row].m_connections & 0b00110000);
|
||||
|
@ -5,14 +5,15 @@
|
||||
#ifndef SOURCE_ABSTRACTIONLAYER_1_H
|
||||
#define SOURCE_ABSTRACTIONLAYER_1_H
|
||||
|
||||
#include "../AbstraktionLayer_Base.h"
|
||||
#include "AbstractionLayer_1_Properties.h"
|
||||
#include "../AbstraktionLayer_Base.h"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <bitset>
|
||||
#include <random>
|
||||
|
||||
class AbstractionLayer_1 : public AbstraktionLayer_Base<AbstractionLayer_1_Properties>
|
||||
class AbstractionLayer_1 : public AbstractionLayer_Base<AbstractionLayer_1_Properties>
|
||||
{
|
||||
public:
|
||||
void PreProcessing(const vector<Part*>* partArray);//override
|
||||
|
@ -6,7 +6,6 @@
|
||||
#define SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "AbstractionLayer_1.h"
|
||||
|
||||
class AbstractionLayer_1_Properties
|
||||
{
|
||||
|
Reference in New Issue
Block a user