Segmented off loop progression
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
78d259dc59
commit
98e1326287
@ -51,18 +51,10 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
};
|
};
|
||||||
std::vector<ScoreData>dataA,dataB;
|
std::vector<ScoreData>dataA,dataB;
|
||||||
std::vector<std::pair<int,int>>player1Score,player2Score,player3Score;
|
std::vector<std::pair<int,int>>player1Score,player2Score,player3Score;
|
||||||
void Evaluate(){
|
std::vector<TestCase>cases;
|
||||||
std::vector<TestCase>cases;
|
std::vector<SongCombinations> bestComboA,bestComboB;
|
||||||
for(int i=0;i<5;i++){
|
int calculationStep=0;
|
||||||
for(int j=0;j<5;j++){
|
void Evaluate(int caseInd,bool ASet){
|
||||||
for(int k=0;k<5;k++){
|
|
||||||
if(i+j+k==6){
|
|
||||||
cases.push_back(TestCase{i,j,k});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ChooseSong = [](SongCombinations&combinations,std::vector<ScoreData>&dat,int index){
|
auto ChooseSong = [](SongCombinations&combinations,std::vector<ScoreData>&dat,int index){
|
||||||
if(combinations.remainingA>0&&combinations.p1Picked.count(index)==0&&combinations.p2Picked.count(index)==0&&combinations.p3Picked.count(index)==0){
|
if(combinations.remainingA>0&&combinations.p1Picked.count(index)==0&&combinations.p2Picked.count(index)==0&&combinations.p3Picked.count(index)==0){
|
||||||
combinations.remainingA--;
|
combinations.remainingA--;
|
||||||
@ -84,13 +76,11 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<SongCombinations> bestComboA,bestComboB;
|
if(ASet){
|
||||||
int caseInd=0;
|
|
||||||
for(TestCase&_case:cases){
|
|
||||||
bestComboA.push_back({});
|
bestComboA.push_back({});
|
||||||
bestComboA[caseInd].remainingA=_case.p1Amt;
|
bestComboA[caseInd].remainingA=cases[caseInd].p1Amt;
|
||||||
bestComboA[caseInd].remainingB=_case.p2Amt;
|
bestComboA[caseInd].remainingB=cases[caseInd].p2Amt;
|
||||||
bestComboA[caseInd].remainingC=_case.p3Amt;
|
bestComboA[caseInd].remainingC=cases[caseInd].p3Amt;
|
||||||
SongCombinations testCombo=bestComboA[caseInd];
|
SongCombinations testCombo=bestComboA[caseInd];
|
||||||
for(int i=0;i<12;i++){
|
for(int i=0;i<12;i++){
|
||||||
SongCombinations c1=testCombo;
|
SongCombinations c1=testCombo;
|
||||||
@ -113,7 +103,7 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
if(bestComboA[caseInd].totalEX<c6.totalEX){
|
if(bestComboA[caseInd].totalEX<c6.totalEX){
|
||||||
bestComboA[caseInd]=c6;
|
bestComboA[caseInd]=c6;
|
||||||
bestComboA[caseInd].totalEX=c6.totalEX;
|
bestComboA[caseInd].totalEX=c6.totalEX;
|
||||||
std::cout<<"New Best Song Combinations found for Case ("<<_case.p1Amt<<","<<_case.p2Amt<<","<<_case.p3Amt<<") - Total EX: "<<bestComboA[caseInd].totalEX<<":"<<std::endl;
|
std::cout<<"New Best Song Combinations found for Case ("<<cases[caseInd].p1Amt<<","<<cases[caseInd].p2Amt<<","<<cases[caseInd].p3Amt<<") - Total EX: "<<bestComboA[caseInd].totalEX<<":"<<std::endl;
|
||||||
std::cout<<"\t";
|
std::cout<<"\t";
|
||||||
for(std::pair<int,int>&p1:bestComboA[caseInd].p1){
|
for(std::pair<int,int>&p1:bestComboA[caseInd].p1){
|
||||||
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
||||||
@ -132,15 +122,11 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
caseInd++;
|
}else{
|
||||||
}
|
|
||||||
|
|
||||||
caseInd=0;
|
|
||||||
for(TestCase&_case:cases){
|
|
||||||
bestComboB.push_back({});
|
bestComboB.push_back({});
|
||||||
bestComboB[caseInd].remainingA=_case.p1Amt;
|
bestComboB[caseInd].remainingA=cases[caseInd].p1Amt;
|
||||||
bestComboB[caseInd].remainingB=_case.p2Amt;
|
bestComboB[caseInd].remainingB=cases[caseInd].p2Amt;
|
||||||
bestComboB[caseInd].remainingC=_case.p3Amt;
|
bestComboB[caseInd].remainingC=cases[caseInd].p3Amt;
|
||||||
SongCombinations testCombo=bestComboB[caseInd];
|
SongCombinations testCombo=bestComboB[caseInd];
|
||||||
for(int i=0;i<12;i++){
|
for(int i=0;i<12;i++){
|
||||||
SongCombinations c1=testCombo;
|
SongCombinations c1=testCombo;
|
||||||
@ -163,7 +149,7 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
if(bestComboB[caseInd].totalEX<c6.totalEX){
|
if(bestComboB[caseInd].totalEX<c6.totalEX){
|
||||||
bestComboB[caseInd]=c6;
|
bestComboB[caseInd]=c6;
|
||||||
bestComboB[caseInd].totalEX=c6.totalEX;
|
bestComboB[caseInd].totalEX=c6.totalEX;
|
||||||
std::cout<<"New Best Song Combinations found for Case ("<<_case.p1Amt<<","<<_case.p2Amt<<","<<_case.p3Amt<<") - Total EX: "<<bestComboB[caseInd].totalEX<<":"<<std::endl;
|
std::cout<<"New Best Song Combinations found for Case ("<<cases[caseInd].p1Amt<<","<<cases[caseInd].p2Amt<<","<<cases[caseInd].p3Amt<<") - Total EX: "<<bestComboB[caseInd].totalEX<<":"<<std::endl;
|
||||||
std::cout<<"\t";
|
std::cout<<"\t";
|
||||||
for(std::pair<int,int>&p1:bestComboB[caseInd].p1){
|
for(std::pair<int,int>&p1:bestComboB[caseInd].p1){
|
||||||
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
||||||
@ -182,43 +168,8 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
caseInd++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int highestEX=0;
|
|
||||||
SongCombinations picked1,picked2;
|
|
||||||
for(SongCombinations&A:bestComboA){
|
|
||||||
for(SongCombinations&B:bestComboB){
|
|
||||||
if(A.totalEX+B.totalEX>highestEX&&A.p1Picked.size()+B.p1Picked.size()==4&&A.p2Picked.size()+B.p2Picked.size()==4&&A.p3Picked.size()+B.p3Picked.size()==4){
|
|
||||||
highestEX=A.totalEX+B.totalEX;
|
|
||||||
picked1=A;
|
|
||||||
picked2=B;
|
|
||||||
std::cout<<"New Best Song Combinations found for Final Picks - Total EX: "<<highestEX<<":"<<std::endl;
|
|
||||||
std::cout<<"\t Set A: ";
|
|
||||||
for(std::pair<int,int>&p1:picked1.p1){
|
|
||||||
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
|
||||||
}
|
|
||||||
for(std::pair<int,int>&p2:picked1.p2){
|
|
||||||
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
|
||||||
}
|
|
||||||
for(std::pair<int,int>&p3:picked1.p3){
|
|
||||||
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
|
||||||
}
|
|
||||||
std::cout<<std::endl;
|
|
||||||
std::cout<<"\t Set B: ";
|
|
||||||
for(std::pair<int,int>&p1:picked2.p1){
|
|
||||||
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
|
||||||
}
|
|
||||||
for(std::pair<int,int>&p2:picked2.p2){
|
|
||||||
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
|
||||||
}
|
|
||||||
for(std::pair<int,int>&p3:picked2.p3){
|
|
||||||
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
|
||||||
}
|
|
||||||
std::cout<<std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
calculationStep++;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
struct SongElement{
|
struct SongElement{
|
||||||
@ -227,6 +178,8 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
p1Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192,0},{36,12});
|
p1Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192,0},{36,12});
|
||||||
p2Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192+42*1,0},{36,12});
|
p2Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192+42*1,0},{36,12});
|
||||||
p3Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192+42*2,0},{36,12});
|
p3Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192+42*2,0},{36,12});
|
||||||
|
|
||||||
|
//NOTE for future Sig: The Text Entry mode has the enter key functionality DISABLED as we use it for tab/enter key navigation. If you need it for some reason you need to go re-enable it.
|
||||||
if(prevTextBox!=nullptr){
|
if(prevTextBox!=nullptr){
|
||||||
prevTextBox->tabNext=p1Score;
|
prevTextBox->tabNext=p1Score;
|
||||||
}
|
}
|
||||||
@ -244,6 +197,12 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
};
|
};
|
||||||
QuickGUI::Manager gui;
|
QuickGUI::Manager gui;
|
||||||
std::vector<SongElement>songs;
|
std::vector<SongElement>songs;
|
||||||
|
QuickGUI::Label*p1Label;
|
||||||
|
QuickGUI::Label*p2Label;
|
||||||
|
QuickGUI::Label*p3Label;
|
||||||
|
QuickGUI::Button*calculateButton;
|
||||||
|
int totalCalculationSteps=0;
|
||||||
|
bool calculating=false;
|
||||||
|
|
||||||
ChampionsLeaguePointSolver()
|
ChampionsLeaguePointSolver()
|
||||||
{
|
{
|
||||||
@ -302,14 +261,94 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
|||||||
}
|
}
|
||||||
std::cout<<"==================="<<std::endl;
|
std::cout<<"==================="<<std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
p1Label=new QuickGUI::Label(gui,"P1",vf2d{4.f,2.f}+vf2d{192,0},{36,12});
|
||||||
|
p2Label=new QuickGUI::Label(gui,"P2",vf2d{4.f,2.f}+vf2d{192+42*1,0},{36,12});
|
||||||
|
p3Label=new QuickGUI::Label(gui,"P3",vf2d{4.f,2.f}+vf2d{192+42*2,0},{36,12});
|
||||||
|
calculateButton=new QuickGUI::Button(gui,"Calculate",{4,2},{100,16});
|
||||||
|
|
||||||
|
for(int i=0;i<5;i++){
|
||||||
|
for(int j=0;j<5;j++){
|
||||||
|
for(int k=0;k<5;k++){
|
||||||
|
if(i+j+k==6){
|
||||||
|
cases.push_back(TestCase{i,j,k});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
{
|
{
|
||||||
Clear(VERY_DARK_CYAN);
|
Clear(VERY_DARK_CYAN);
|
||||||
|
|
||||||
|
if(calculateButton->bPressed&&!calculating){
|
||||||
|
calculateButton->Enable(false);
|
||||||
|
for(SongElement&element:songs){
|
||||||
|
element.p1Score->Enable(false);
|
||||||
|
element.p2Score->Enable(false);
|
||||||
|
element.p3Score->Enable(false);
|
||||||
|
}
|
||||||
|
calculating=true;
|
||||||
|
calculationStep=0;
|
||||||
|
totalCalculationSteps=cases.size()*2;
|
||||||
|
bestComboA={};
|
||||||
|
bestComboB={};
|
||||||
|
}
|
||||||
gui.Update(this);
|
gui.Update(this);
|
||||||
gui.Draw(this);
|
gui.Draw(this);
|
||||||
|
if(calculating){
|
||||||
|
if(calculationStep<cases.size()){
|
||||||
|
Evaluate(calculationStep,true);
|
||||||
|
}else{
|
||||||
|
Evaluate(calculationStep%cases.size(),false);
|
||||||
|
}
|
||||||
|
|
||||||
|
FillRect({0,ScreenHeight()-12},{ScreenWidth(),12},DARK_GREY);
|
||||||
|
FillRect({0,ScreenHeight()-12},{int(calculationStep/float(totalCalculationSteps)*ScreenWidth()),12},WHITE);
|
||||||
|
DrawRect({0,ScreenHeight()-12},{ScreenWidth(),12},BLACK);
|
||||||
|
|
||||||
|
if(calculationStep==totalCalculationSteps){
|
||||||
|
int highestEX=0;
|
||||||
|
SongCombinations picked1,picked2;
|
||||||
|
for(SongCombinations&A:bestComboA){
|
||||||
|
for(SongCombinations&B:bestComboB){
|
||||||
|
if(A.totalEX+B.totalEX>highestEX&&A.p1Picked.size()+B.p1Picked.size()==4&&A.p2Picked.size()+B.p2Picked.size()==4&&A.p3Picked.size()+B.p3Picked.size()==4){
|
||||||
|
highestEX=A.totalEX+B.totalEX;
|
||||||
|
picked1=A;
|
||||||
|
picked2=B;
|
||||||
|
std::cout<<"New Best Song Combinations found for Final Picks - Total EX: "<<highestEX<<":"<<std::endl;
|
||||||
|
std::cout<<"\t Set A: ";
|
||||||
|
for(std::pair<int,int>&p1:picked1.p1){
|
||||||
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
||||||
|
}
|
||||||
|
for(std::pair<int,int>&p2:picked1.p2){
|
||||||
|
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
||||||
|
}
|
||||||
|
for(std::pair<int,int>&p3:picked1.p3){
|
||||||
|
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl;
|
||||||
|
std::cout<<"\t Set B: ";
|
||||||
|
for(std::pair<int,int>&p1:picked2.p1){
|
||||||
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
||||||
|
}
|
||||||
|
for(std::pair<int,int>&p2:picked2.p2){
|
||||||
|
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
||||||
|
}
|
||||||
|
for(std::pair<int,int>&p3:picked2.p3){
|
||||||
|
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
||||||
|
}
|
||||||
|
std::cout<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
calculating=false;
|
||||||
|
calculateButton->bPressed=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user