NON FINAL: added dp calculation and most of RW code, included david code

still not runable code as dispatcher functions are only placeholders!
This commit is contained in:
Raphael Maenle 2017-12-23 21:46:41 +01:00
parent 7c5cfc8c6b
commit caa74198bd
3 changed files with 54 additions and 41 deletions

View File

@ -25,5 +25,8 @@ public:
void DestructionOfSurrounding(coor constraintCoordinate); void DestructionOfSurrounding(coor constraintCoordinate);
int getNextAbstractionLayer(coor newCoordinate, int currentAbstractionLayer); int getNextAbstractionLayer(coor newCoordinate, int currentAbstractionLayer);
void setDestructionPower(coor myCoor, int AbstractionLevel, float destructionPower)
{ m_constraintMatrix[myCoor.col][myCoor.row].DestructionArray[AbstractionLevel] = destructionPower;}
private: private:
}; };

View File

@ -14,13 +14,13 @@ class DestructionPower_Properties
{ {
public: public:
explicit DestructionPower_Properties(); explicit DestructionPower_Properties();
map<int,float> getSpeedTable() {return SpeedTable;}
void setSpeedTable(); void setSpeedTable();
static map<int,float> SpeedTable;
vector<float> DestructionArray;
private: private:
static map<int,float> SpeedTable;
vector<float> DestructionArray;
friend class DestructionPower; friend class DestructionPower;
}; };

View File

@ -2,7 +2,10 @@
void status(vector<LogEntry>& log, vector<Part*>& p_Box); void status(vector<LogEntry>& log, vector<Part*>& p_Box);
bool setBestOrMoreLayers(vector<LogEntry>& log); bool setBestOrMoreLayers(vector<LogEntry>& log);
void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth); void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth);
void capLogElements(vector<LogEntry>& log); void sort(vector<LogEntry>& log);
void cut(vector<LogEntry>& log, Part* cutID);
float capLogElements(vector<LogEntry>& log);
void calculateNewCombinedProbabilityForPuzzlePiecesArithmetic(vector<LogEntry>& log);
bool next(vector<LogEntry>& log, vector<Part*>& p_Box,Puzzle& puzzleMat) bool next(vector<LogEntry>& log, vector<Part*>& p_Box,Puzzle& puzzleMat)
{ {
@ -81,10 +84,10 @@ void solve(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
break; break;
} }
//capLogElements(log); capLogElements(log);
//calculateWorth(log); float worth = capLogElements(log);
//calculateTrueDestructionPower(log,puzzleMat); calculateTrueDestructionPower(log,puzzleMat, worth);
//calculateNewCombinedProbablility(log); calculateNewCombinedProbabilityForPuzzlePiecesArithmetic(log);
} }
@ -156,24 +159,16 @@ void status(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
cout << "----------------------------" << endl; cout << "----------------------------" << endl;
} }
void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth) //this is addon stuff that should later all be extracted into a sererate cpp as it is not core dispatcher functionality
{
//hier muss noch rein, wo die zeit der Abstractionlevels gespeichter wird void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth) {
float destructionPower=sqrt(Layerworth * log.back().abstractionLevel); float destructionPower = sqrt(
//puzzleMat.setdestructionPower(log.back().myCoor,log.back().abstractionLevel,destructionPower); Layerworth * puzzleMat.dp.m_constraintMatrix[0][0].SpeedTable[log.back().abstractionLevel]);
puzzleMat.dp.setDestructionPower(log.back().myCoor, log.back().abstractionLevel, destructionPower);
} }
// PART RAUER_WEIDINGER // PART RAUER_WEIDINGER
/* float capLogElements(vector<LogEntry>& log)
void sort()
{
}
void cut()
{
}
void capLogElements(vector<LogEntry>& log)
{ {
// Till Now only ground structure -> incorrect variable ans vector names // Till Now only ground structure -> incorrect variable ans vector names
double limit = 0.6; double limit = 0.6;
@ -186,34 +181,50 @@ void capLogElements(vector<LogEntry>& log)
vectorsizeBefore = log.back().PieceCollector.size(); vectorsizeBefore = log.back().PieceCollector.size();
sort(); // Sort the vector after probabilities sort(log); // Sort the vector after probabilities
auto idxcut; std::map<Part*,float>::const_iterator idxcut =log.back().PieceCollector.begin();
for(idxcut:log.back().PieceCollector) for(;idxcut !=log.back().PieceCollector.end();idxcut++)
if(idxcut.second < limit) if(idxcut->second < limit)
break; break;
auto newidxcut = idxcut;
while(idxcut != log.back().PieceCollector.end()) while(idxcut != log.back().PieceCollector.end())
{ {
diff = part[i] - part[i+1]; diff = idxcut->second - (++idxcut)->second;
if(diff > maxdiff) if(diff > maxdiff)
{ {
maxdiff = diff; maxdiff = diff;
idxcut = i; newidxcut = idxcut;
} }
i++;
} }
cut(); cut(log,newidxcut->first);
vectorsizeAfter = vector.size(); vectorsizeAfter = log.back().PieceCollector.size();
destroyed = (vectorsizeBefore - vectorsizeAfter) / vectorsizeBefore; destroyed = (vectorsizeBefore - vectorsizeAfter) / vectorsizeBefore;
worth = sqrt(destroyed*maxdiff); return (float)sqrt(destroyed*maxdiff);
//return worth; }
void sort(vector<LogEntry>& log)
{
//this does all the sorting that needs to happen
//saddly this is a false statement
//the monkey desperately tried to hold on to the flying dorm room.
}
void cut(vector<LogEntry>& log, Part* cutID)
{
auto it = log.back().PieceCollector.find(cutID)++;
while(it != log.back().PieceCollector.end())
log.back().PieceCollector.erase(it++);
}
} */
//partdavid //partdavid
bool setBestOrMoreLayers(vector<LogEntry>& log) bool setBestOrMoreLayers(vector<LogEntry>& log)
@ -248,11 +259,10 @@ void calculateNewCombinedProbabilityForPuzzlePiecesArithmetic(vector<LogEntry>&
{ {
float totalValue = 0.0; float totalValue = 0.0;
int i; int i;
for(int i; i < log.back().PieceCollector.size(); i++) for(int i; i < log.back().PieceCollector.size(); i++);
{
// sum Probability of current Puzzle Piece in PieceCollector vector // sum Probability of current Puzzle Piece in PieceCollector vector
//totalValue += *(log.back().PieceCollector.); //totalValue += *(log.back().PieceCollector.);
}
//return totalValue / i; //return totalValue / i;
} }