diff --git a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp index 71de8e2..108efe5 100644 --- a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp +++ b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp @@ -10,10 +10,10 @@ std::string slurp(std::ifstream& in) { } struct ScoreData{ - int difficulty; + int difficulty=0; std::string song; - int totalEX; - int ex1,ex2,ex3; + int totalEX=0; + int ex1=0,ex2=0,ex3=0; std::string str()const{ return "["+std::to_string(difficulty)+"] "+song+": "+std::to_string(totalEX)+" total, "+" EX1: "+std::to_string(ex1)+" EX2: "+std::to_string(ex2)+" EX3: "+std::to_string(ex3); } @@ -23,6 +23,11 @@ struct ScoreData{ } }; +struct Selection{ + std::vector>selectedScore; + int totalEX=0; +}; + std::string GetNext(int&marker,std::string str){ int originalMarker=marker; marker=str.find_first_of(',',originalMarker)+1; @@ -30,7 +35,6 @@ std::string GetNext(int&marker,std::string str){ }; int main(){ - std::vectordataA,dataB; std::ifstream file("team.csv"); std::string line; @@ -64,10 +68,89 @@ int main(){ stoi(GetNext(marker,line))} ); } - + std::cout<<"File Contents:"<bestSelections; + while(true){ + int Aselections=6,Bselections=6; + Selection selection; + int totalEX=0; + int hash=0; + std::vectorrandomChoice={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}; + for(int iSel=0;iSel<4;iSel++){ + int arrInd=rand()%randomChoice.size(); + int randSongIndex=randomChoice[arrInd]; + randomChoice.erase(randomChoice.begin()+arrInd); + ScoreData*dataRef; + if(randSongIndex<12){ + Aselections--; + dataRef=&dataA[randSongIndex]; + }else{ + Bselections--; + dataRef=&dataB[randSongIndex-12]; + } + selection.selectedScore.push_back({0,randSongIndex}); + selection.totalEX+=dataRef->ex1; + totalEX+=dataRef->ex1; + } + for(int iSel=0;iSel<4;iSel++){ + int arrInd=rand()%randomChoice.size(); + int randSongIndex=randomChoice[arrInd]; + while(Aselections==0&&randSongIndex<12||Bselections==0&&randSongIndex>=12){ + arrInd=rand()%randomChoice.size(); + randSongIndex=randomChoice[arrInd]; + } + randomChoice.erase(randomChoice.begin()+arrInd); + ScoreData*dataRef; + if(randSongIndex<12){ + Aselections--; + dataRef=&dataA[randSongIndex]; + }else{ + Bselections--; + dataRef=&dataB[randSongIndex-12]; + } + selection.selectedScore.push_back({1,randSongIndex}); + selection.totalEX+=dataRef->ex2; + totalEX+=dataRef->ex2; + } + for(int iSel=0;iSel<4;iSel++){ + int arrInd=rand()%randomChoice.size(); + int randSongIndex=randomChoice[arrInd]; + while(Aselections==0&&randSongIndex<12||Bselections==0&&randSongIndex>=12){ + arrInd=rand()%randomChoice.size(); + randSongIndex=randomChoice[arrInd]; + } + randomChoice.erase(randomChoice.begin()+arrInd); + ScoreData*dataRef; + if(randSongIndex<12){ + Aselections--; + dataRef=&dataA[randSongIndex]; + }else{ + Bselections--; + dataRef=&dataB[randSongIndex-12]; + } + selection.selectedScore.push_back({2,randSongIndex}); + selection.totalEX+=dataRef->ex3; + totalEX+=dataRef->ex3; + } + if(bestSelections.size()>0){ + int bestEX=bestSelections.back().totalEX; + if(totalEX>bestEX){ + std::cout<<"New best EX combination found: "+std::to_string(totalEX)+". Selections are:"<&song:selection.selectedScore){ + std::cout<<"P"<