diff --git a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp index 108efe5..736e1ad 100644 --- a/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp +++ b/ChallengeLeaguePointSolver/ChallengeLeaguePointSolver.cpp @@ -2,6 +2,7 @@ #include #include #include +#include std::string slurp(std::ifstream& in) { std::ostringstream sstr; @@ -76,80 +77,255 @@ int main(){ } std::cout<<"==================="<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]; + Selection selection; + ScoreData*dataRef; + std::vectorsortedChoices={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}; + std::sort(sortedChoices.begin(),sortedChoices.end(),[&](int&val1,int&val2){ + int ex1; + int ex2; + if(val1<12){ + ex1=dataA[val1].totalEX; }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]; + ex1=dataB[val1-12].totalEX; } - randomChoice.erase(randomChoice.begin()+arrInd); - ScoreData*dataRef; - if(randSongIndex<12){ - Aselections--; - dataRef=&dataA[randSongIndex]; + if(val2<12){ + ex2=dataA[val2].totalEX; }else{ - Bselections--; - dataRef=&dataB[randSongIndex-12]; + ex2=dataB[val2-12].totalEX; } - selection.selectedScore.push_back({1,randSongIndex}); - selection.totalEX+=dataRef->ex2; - totalEX+=dataRef->ex2; + return ex1>ex2; + }); + + for(int a1=0;a1<24;a1++){ + int Aselections=6,Bselections=6; + selection.selectedScore.clear(); + selection.totalEX=0; + std::vectorremainingChoices=sortedChoices; + int arrInd=a1; + if(Aselections==0&&remainingChoices[a1]<12||Bselections==0&&remainingChoices[a1]>=12)continue; + selection.selectedScore.push_back({0,remainingChoices[arrInd]}); + if(remainingChoices[arrInd]<12){ + Aselections--; + dataRef=&dataA[remainingChoices[arrInd]]; + }else{ + Bselections--; + dataRef=&dataB[remainingChoices[arrInd]-12]; } - 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]; + selection.totalEX+=dataRef->ex1; + remainingChoices.erase(remainingChoices.begin()+arrInd); + for(int a2=0;a2<23;a2++){ + Selection selection2 = selection; + int Aselections2=Aselections,Bselections2=Bselections; + std::vectorremainingChoices2 = remainingChoices; + int arrInd=a2; + if(Aselections2==0&&remainingChoices2[a2]<12||Bselections2==0&&remainingChoices2[a2]>=12)continue; + selection2.selectedScore.push_back({0,remainingChoices2[arrInd]}); + if(remainingChoices2[arrInd]<12){ + Aselections2--; + dataRef=&dataA[remainingChoices2[arrInd]]; }else{ - Bselections--; - dataRef=&dataB[randSongIndex-12]; + Bselections2--; + dataRef=&dataB[remainingChoices2[arrInd]-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"<ex1; + remainingChoices2.erase(remainingChoices2.begin()+arrInd); + if(bestSelections.size()>0&&selection2.totalEXremainingChoices3 = remainingChoices2; + int Aselections3=Aselections2,Bselections3=Bselections2; + int arrInd=a3; + if(Aselections3==0&&remainingChoices3[a3]<12||Bselections3==0&&remainingChoices3[a3]>=12)continue; + selection3.selectedScore.push_back({0,remainingChoices3[arrInd]}); + if(remainingChoices3[arrInd]<12){ + Aselections3--; + dataRef=&dataA[remainingChoices3[arrInd]]; + }else{ + Bselections3--; + dataRef=&dataB[remainingChoices3[arrInd]-12]; + } + selection3.totalEX+=dataRef->ex1; + remainingChoices3.erase(remainingChoices3.begin()+arrInd); + if(bestSelections.size()>0&&selection3.totalEXremainingChoices4 = remainingChoices3; + int Aselections4=Aselections3,Bselections4=Bselections3; + int arrInd=a4; + if(Aselections4==0&&remainingChoices4[a4]<12||Bselections4==0&&remainingChoices4[a4]>=12)continue; + selection4.selectedScore.push_back({0,remainingChoices4[arrInd]}); + if(remainingChoices4[arrInd]<12){ + Aselections4--; + dataRef=&dataA[remainingChoices4[arrInd]]; + }else{ + Bselections4--; + dataRef=&dataB[remainingChoices4[arrInd]-12]; + } + selection4.totalEX+=dataRef->ex1; + remainingChoices4.erase(remainingChoices4.begin()+arrInd); + if(bestSelections.size()>0&&selection4.totalEXremainingChoices5 = remainingChoices4; + int Aselections5=Aselections4,Bselections5=Bselections4; + int arrInd=b1; + if(Aselections5==0&&remainingChoices5[b1]<12||Bselections5==0&&remainingChoices5[b1]>=12)continue; + selection5.selectedScore.push_back({1,remainingChoices5[arrInd]}); + if(remainingChoices5[arrInd]<12){ + Aselections5--; + dataRef=&dataA[remainingChoices5[arrInd]]; + }else{ + Bselections5--; + dataRef=&dataB[remainingChoices5[arrInd]-12]; + } + selection5.totalEX+=dataRef->ex2; + remainingChoices5.erase(remainingChoices5.begin()+arrInd); + if(bestSelections.size()>0&&selection5.totalEXremainingChoices6 = remainingChoices5; + int Aselections6=Aselections5,Bselections6=Bselections5; + int arrInd=b2; + if(Aselections6==0&&remainingChoices6[b2]<12||Bselections6==0&&remainingChoices6[b2]>=12)continue; + selection6.selectedScore.push_back({1,remainingChoices6[arrInd]}); + if(remainingChoices6[arrInd]<12){ + Aselections6--; + dataRef=&dataA[remainingChoices6[arrInd]]; + }else{ + Bselections6--; + dataRef=&dataB[remainingChoices6[arrInd]-12]; + } + selection6.totalEX+=dataRef->ex2; + remainingChoices6.erase(remainingChoices6.begin()+arrInd); + if(bestSelections.size()>0&&selection6.totalEXremainingChoices7 = remainingChoices6; + int Aselections7=Aselections6,Bselections7=Bselections6; + int arrInd=b3; + if(Aselections7==0&&remainingChoices7[b3]<12||Bselections7==0&&remainingChoices7[b3]>=12)continue; + selection7.selectedScore.push_back({1,remainingChoices7[arrInd]}); + if(remainingChoices7[arrInd]<12){ + Aselections7--; + dataRef=&dataA[remainingChoices7[arrInd]]; + }else{ + Bselections7--; + dataRef=&dataB[remainingChoices7[arrInd]-12]; + } + selection7.totalEX+=dataRef->ex2; + remainingChoices7.erase(remainingChoices7.begin()+arrInd); + if(bestSelections.size()>0&&selection7.totalEXremainingChoices8 = remainingChoices7; + int Aselections8=Aselections7,Bselections8=Bselections7; + int arrInd=b4; + if(Aselections8==0&&remainingChoices8[b4]<12||Bselections8==0&&remainingChoices8[b4]>=12)continue; + selection8.selectedScore.push_back({1,remainingChoices8[arrInd]}); + if(remainingChoices8[arrInd]<12){ + Aselections8--; + dataRef=&dataA[remainingChoices8[arrInd]]; + }else{ + Bselections8--; + dataRef=&dataB[remainingChoices8[arrInd]-12]; + } + selection8.totalEX+=dataRef->ex2; + remainingChoices8.erase(remainingChoices8.begin()+arrInd); + if(bestSelections.size()>0&&selection8.totalEXremainingChoices9 = remainingChoices8; + int Aselections9=Aselections8,Bselections9=Bselections8; + int arrInd=c1; + if(Aselections9==0&&remainingChoices9[c1]<12||Bselections9==0&&remainingChoices9[c1]>=12)continue; + selection9.selectedScore.push_back({2,remainingChoices9[arrInd]}); + if(remainingChoices9[arrInd]<12){ + Aselections9--; + dataRef=&dataA[remainingChoices9[arrInd]]; + }else{ + Bselections9--; + dataRef=&dataB[remainingChoices9[arrInd]-12]; + } + selection9.totalEX+=dataRef->ex3; + remainingChoices9.erase(remainingChoices9.begin()+arrInd); + if(bestSelections.size()>0&&selection9.totalEXremainingChoices10 = remainingChoices9; + int Aselections10=Aselections9,Bselections10=Bselections9; + int arrInd=c2; + if(Aselections10==0&&remainingChoices10[c2]<12||Bselections10==0&&remainingChoices10[c2]>=12)continue; + selection10.selectedScore.push_back({2,remainingChoices10[arrInd]}); + if(remainingChoices10[arrInd]<12){ + Aselections10--; + dataRef=&dataA[remainingChoices10[arrInd]]; + }else{ + Bselections10--; + dataRef=&dataB[remainingChoices10[arrInd]-12]; + } + selection10.totalEX+=dataRef->ex3; + remainingChoices10.erase(remainingChoices10.begin()+arrInd); + if(bestSelections.size()>0&&selection10.totalEXremainingChoices11 = remainingChoices10; + int Aselections11=Aselections10,Bselections11=Bselections10; + int arrInd=c3; + if(Aselections11==0&&remainingChoices11[c3]<12||Bselections11==0&&remainingChoices11[c3]>=12)continue; + selection11.selectedScore.push_back({2,remainingChoices11[arrInd]}); + if(remainingChoices11[arrInd]<12){ + Aselections11--; + dataRef=&dataA[remainingChoices11[arrInd]]; + }else{ + Bselections11--; + dataRef=&dataB[remainingChoices11[arrInd]-12]; + } + selection11.totalEX+=dataRef->ex3; + remainingChoices11.erase(remainingChoices11.begin()+arrInd); + if(bestSelections.size()>0&&selection11.totalEXremainingChoices12 = remainingChoices11; + int Aselections12=Aselections11,Bselections12=Bselections11; + int arrInd=c4; + if(Aselections12==0&&remainingChoices12[c4]<12||Bselections12==0&&remainingChoices12[c4]>=12)continue; + selection12.selectedScore.push_back({2,remainingChoices12[arrInd]}); + if(remainingChoices12[arrInd]<12){ + Aselections12--; + dataRef=&dataA[remainingChoices12[arrInd]]; + }else{ + Bselections12--; + dataRef=&dataB[remainingChoices12[arrInd]-12]; + } + selection12.totalEX+=dataRef->ex3; + if(bestSelections.size()>0){ + int bestEX=bestSelections.back().totalEX; + if(selection12.totalEX>bestEX){ + std::cout<<"New best EX combination found: "+std::to_string(selection12.totalEX)+". Selections are:"<&song:selection12.selectedScore){ + std::cout<<"P"<&song:selection12.selectedScore){ + std::cout<<"P"<