#include "DestructionPower.h" //TODO! Add more layers here! //sets relations of speed for the different layers map DestructionPower_Properties::SpeedTable = { {0,0.99}, {1,0.7}, {2,0.7}, {3,0.5} }; bool DestructionPower::PreProcessing(coor mySize,const vector* partArray) { cout << "DestructionPower Preprocessing... "; InitialiseConstraintMatrixSize(mySize.col,mySize.row); for(auto& it:m_constraintMatrix) for(auto& ti:it) for(int i=0;i 0 && m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row-1].DestructionArray[i] > 0) { divisor++; m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i] += m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row-1].DestructionArray[i]; } if(constraintCoordinate.col > 0 && m_constraintMatrix[constraintCoordinate.col-1][constraintCoordinate.row].DestructionArray[i] > 0) { divisor++; m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i] += m_constraintMatrix[constraintCoordinate.col-1][constraintCoordinate.row].DestructionArray[i]; } if(constraintCoordinate.col < m_constraintMatrix.size()-1 && m_constraintMatrix[constraintCoordinate.col+1][constraintCoordinate.row].DestructionArray[i] > 0) { divisor++; m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i] += m_constraintMatrix[constraintCoordinate.col+1][constraintCoordinate.row].DestructionArray[i]; } if(constraintCoordinate.row < m_constraintMatrix[i].size()-1 && m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row+1].DestructionArray[i] > 0) { divisor++; m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i] += m_constraintMatrix[constraintCoordinate.col-1][constraintCoordinate.row].DestructionArray[i]; } if(divisor) m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i] /=divisor; else //create default destructionPower //TODO find some better solution for default m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i] = m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].SpeedTable[i]; //aging if(m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i]<0.9) m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i]=m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].DestructionArray[i]*(float)1.001+(float)0.01; } } //gets next highest valued abstraction layer down from current one (if first, get highest) int DestructionPower::getNextAbstractionLayer(coor newCoordinate, int currentAbstractionLayer) { //hardcode advance // if(currentAbstractionLayer=0) currentPower = m_constraintMatrix[newCoordinate.col][newCoordinate.row].DestructionArray[currentAbstractionLayer]; int i=0; //giff next most valuable layer for(auto it:m_constraintMatrix[newCoordinate.col][newCoordinate.row].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 else if(it>nextLayerPower) { nextLayerPower=it; nextLayer=i; } } i++; } return nextLayer; } DestructionPower_Properties::DestructionPower_Properties() { float aging=1.001; for(int i=0;i