implemented #1 layer
everything with the excemtion of image recogniation in preprocessing should be fully implemented. Can now begin deleting all legacy code.
This commit is contained in:
parent
507533531c
commit
c885e472fb
@ -11,49 +11,52 @@ void AbstractionLayer_1::PreProcessing(const vector<Part*>* partArray)
|
|||||||
setEdgeZero();
|
setEdgeZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
||||||
bool AbstractionLayer_1::EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector)
|
bool AbstractionLayer_1::EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector)
|
||||||
{
|
{
|
||||||
for(int i=0;i<qVector.size();i++)
|
for(auto it = qualityVector.begin();it!=qualityVector.end();it++)
|
||||||
{
|
{
|
||||||
if(PlaceOfPartGood(constraintCoordinate, qVector[i].Part))
|
if(PlaceOfPartGood(constraintCoordinate,it->first->m_test1.m_connections))
|
||||||
qVector[i].setQuality(1);
|
continue;
|
||||||
else
|
qualityVector.erase(it++);
|
||||||
qVector[i].setQuality(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractionLayer_1::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint)
|
bool AbstractionLayer_1::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint)
|
||||||
{
|
{
|
||||||
m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row]=
|
m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].m_connections=constraint.m_connections;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractionLayer_1::RemoveConstraintOnPosition(const coor constraintCoordinate)
|
bool AbstractionLayer_1::RemoveConstraintOnPosition(const coor constraintCoordinate)
|
||||||
{
|
{
|
||||||
|
m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].m_connections=0b11111111;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractionLayer_1::CreateRandomPuzzle()
|
bool AbstractionLayer_1::CreateRandomPuzzle()
|
||||||
{
|
{
|
||||||
|
std:: minstd_rand simple_rand;
|
||||||
|
simple_rand.seed((unsigned int)"dumbo");
|
||||||
|
|
||||||
for(int col=1;col<m_constraintMatrix.size()-1;col++){
|
for(int col=1;col<m_constraintMatrix.size()-1;col++){
|
||||||
for(int row=1;row<m_constraintMatrix[col].size()-1;)
|
for(int row=1;row<m_constraintMatrix[col].size()-1;)
|
||||||
{
|
{
|
||||||
uint8_t tempPiece = 0b00000000;
|
uint8_t tempPiece = 0b00000000;
|
||||||
if(rand()%2)
|
if(simple_rand()%2)
|
||||||
tempPiece|=0b01000000;
|
tempPiece|=0b01000000;
|
||||||
else
|
else
|
||||||
tempPiece|=0b10000000;
|
tempPiece|=0b10000000;
|
||||||
|
|
||||||
if(rand()%2)
|
if(simple_rand()%2)
|
||||||
tempPiece|=0b00010000;
|
tempPiece|=0b00010000;
|
||||||
else
|
else
|
||||||
tempPiece|=0b00100000;
|
tempPiece|=0b00100000;
|
||||||
|
|
||||||
if(rand()%2)
|
if(simple_rand()%2)
|
||||||
tempPiece|=0b00000100;
|
tempPiece|=0b00000100;
|
||||||
else
|
else
|
||||||
tempPiece|=0b00001000;
|
tempPiece|=0b00001000;
|
||||||
|
|
||||||
if(rand()%2)
|
if(simple_rand()%2)
|
||||||
tempPiece|=0b00000001;
|
tempPiece|=0b00000001;
|
||||||
else
|
else
|
||||||
tempPiece|=0b00000010;
|
tempPiece|=0b00000010;
|
||||||
@ -65,6 +68,20 @@ bool AbstractionLayer_1::CreateRandomPuzzle()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//puts all pieces of the current constraint matrix into a puzzlebox
|
||||||
|
qualityVector AbstractionLayer_1::returnInBox(vector<Part>& PuzzleBox)
|
||||||
|
{
|
||||||
|
if(!(PuzzleBox.size()))
|
||||||
|
for(int i = 0; i< (m_constraintMatrix.size()-2)*(m_constraintMatrix[0].size()-2);i++)
|
||||||
|
PuzzleBox.emplace_back(Part());
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractionLayer_1::setEdgeZero()
|
void AbstractionLayer_1::setEdgeZero()
|
||||||
{
|
{
|
||||||
for(int col=0;col<m_constraintMatrix.size();col++)
|
for(int col=0;col<m_constraintMatrix.size();col++)
|
||||||
|
@ -10,11 +10,12 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
class AbstractionLayer_1 : public AbstraktionLayer_Base<AbstractionLayer_1_Properties>
|
class AbstractionLayer_1 : public AbstraktionLayer_Base<AbstractionLayer_1_Properties>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void PreProcessing(const vector<Part*>* partArray);
|
void PreProcessing(const vector<Part*>* partArray);//override
|
||||||
bool EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector);
|
bool EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector);
|
||||||
bool SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint);
|
bool SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint);
|
||||||
bool RemoveConstraintOnPosition(const coor constraintCoordinate);
|
bool RemoveConstraintOnPosition(const coor constraintCoordinate);
|
||||||
@ -24,6 +25,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
bool CreateRandomPuzzle();
|
bool CreateRandomPuzzle();
|
||||||
|
qualityVector returnInBox(vector<Part>& PuzzleBox);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user