2017-12-20 22:05:04 +01:00
|
|
|
//
|
|
|
|
// Created by mpapa on 05.12.2017.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "DestructionPower.h"
|
2017-12-21 12:20:57 +01:00
|
|
|
|
2017-12-21 13:35:13 +01:00
|
|
|
//TODO! Add more layers here!
|
2017-12-21 12:20:57 +01:00
|
|
|
map<int,float> DestructionPower_Properties::SpeedTable =
|
|
|
|
{
|
|
|
|
{1,0.001}
|
|
|
|
};
|
|
|
|
|
2017-12-20 22:05:04 +01:00
|
|
|
|
2017-12-22 22:55:55 +01:00
|
|
|
void DestructionPower::PreProcessing(coor mySize,const vector<Part*>* partArray)
|
2017-12-20 22:05:04 +01:00
|
|
|
{
|
2017-12-22 22:55:55 +01:00
|
|
|
InitialiseConstraintMatrixSize(mySize.row,mySize.col);
|
2017-12-20 22:05:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
|
|
|
bool DestructionPower::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DestructionPower::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DestructionPower::RemoveConstraintOnPosition(const coor constraintCoordinate)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//gets destruction power from left and from top if possibe and normalizes
|
|
|
|
void DestructionPower::DestructionOfSurrounding(const coor constraintCoordinate) {
|
|
|
|
float newDestructionArray[DESTRUCTION_COUNT];
|
|
|
|
for (int i = 0; i < DESTRUCTION_COUNT; ++i) {
|
|
|
|
int divisor=0;
|
|
|
|
if(constraintCoordinate.row > 0)
|
|
|
|
{
|
|
|
|
divisor++;
|
2017-12-21 12:20:57 +01:00
|
|
|
newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row-1].DestructionArray[i];
|
2017-12-20 22:05:04 +01:00
|
|
|
}
|
|
|
|
if(constraintCoordinate.col > 0)
|
|
|
|
{
|
|
|
|
divisor++;
|
2017-12-21 12:20:57 +01:00
|
|
|
newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col-1][constraintCoordinate.row].DestructionArray[i];
|
2017-12-20 22:05:04 +01:00
|
|
|
}
|
|
|
|
if(divisor)
|
|
|
|
newDestructionArray[i] /=divisor;
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 22:55:55 +01:00
|
|
|
//gets next highest valued abstraction layer down from current one (if first, get highest)
|
|
|
|
int DestructionPower::getNextAbstractionLayer(coor newCoordinate, int currentAbstractionLayer)
|
|
|
|
{
|
|
|
|
float currentPower=-1;
|
|
|
|
int nextLayer=-1;
|
|
|
|
float nextLayerPower=0;
|
|
|
|
if (currentAbstractionLayer>=0)
|
|
|
|
currentPower = m_constraintMatrix[newCoordinate.row][newCoordinate.col].DestructionArray[currentAbstractionLayer];
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
for(float it:m_constraintMatrix[newCoordinate.row][newCoordinate.col].DestructionArray)
|
|
|
|
{
|
|
|
|
if(it <= currentPower)
|
|
|
|
{
|
|
|
|
//if equal, then has to be the next one (activated from left to right)
|
|
|
|
if(it == currentPower)
|
|
|
|
if(i>currentAbstractionLayer)
|
|
|
|
return i;
|
|
|
|
//if this one is bigger than previous biggest one, save
|
|
|
|
if(it>nextLayerPower)
|
|
|
|
{
|
|
|
|
nextLayerPower=it;
|
|
|
|
nextLayer=i;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nextLayer;
|
|
|
|
}
|
2017-12-21 13:35:13 +01:00
|
|
|
|
2017-12-21 12:20:57 +01:00
|
|
|
DestructionPower_Properties::DestructionPower_Properties() {
|
2017-12-21 13:35:13 +01:00
|
|
|
float aging=1.001;
|
|
|
|
for(int i=0;i<DestructionArray.size();i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
DestructionArray.emplace_back((DestructionPower_Properties::SpeedTable[i]*DESTRUCTION_INIT));
|
|
|
|
DestructionArray.back()<0.99 ? DestructionArray.back()*=aging:DestructionArray.back();
|
|
|
|
}
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|