|
|
|
@ -8,95 +8,64 @@ struct Blueprint{ |
|
|
|
|
int oreRobotCost,clayRobotCost,obsidianRobotCost1,obsidianRobotCost2,geodeRobotCost1,geodeRobotCost2; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
int runSimulation(Blueprint print){ |
|
|
|
|
int minute=0; |
|
|
|
|
int ore=0,clay=0,obsidian=0,geodes=0; |
|
|
|
|
int oreRobots=1/*We start with 1 free ore robot*/,clayRobots=0,obsidianRobots=0,geodeRobots=0; |
|
|
|
|
|
|
|
|
|
int oreRequired=print.oreRobotCost+print.clayRobotCost+print.obsidianRobotCost1+print.geodeRobotCost1; |
|
|
|
|
int clayRequired=print.obsidianRobotCost2; |
|
|
|
|
int obsidianRequired=print.geodeRobotCost2; |
|
|
|
|
int geodeRequired=print.geodeRobotCost2; |
|
|
|
|
|
|
|
|
|
int totalRequired=oreRequired+clayRequired+obsidianRequired+1; |
|
|
|
|
enum Priority{ |
|
|
|
|
OREROBOT, |
|
|
|
|
CLAYROBOT, |
|
|
|
|
OBSIDIANROBOT, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
float oreRatio=(float)oreRequired/totalRequired; |
|
|
|
|
float clayRatio=(float)clayRequired/totalRequired; |
|
|
|
|
float obsidianRatio=(float)obsidianRequired/totalRequired; |
|
|
|
|
float geodeRatio=(float)1/totalRequired; |
|
|
|
|
std::string prioToName(Priority p){ |
|
|
|
|
switch(p){ |
|
|
|
|
case OREROBOT:{ |
|
|
|
|
return "Ore Robot"; |
|
|
|
|
}break; |
|
|
|
|
case CLAYROBOT:{ |
|
|
|
|
return "Clay Robot"; |
|
|
|
|
}break; |
|
|
|
|
case OBSIDIANROBOT:{ |
|
|
|
|
return "Obsidian Robot"; |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float orePct=0; |
|
|
|
|
float clayPct=0; |
|
|
|
|
float obsidianPct=0; |
|
|
|
|
float geodePct=0; |
|
|
|
|
std::string bestHistory=""; |
|
|
|
|
|
|
|
|
|
for (int i=0;i<24;i++){ |
|
|
|
|
void runSimulation(Blueprint print, int minute, int ore, int clay, int obsidian, int geodes, int oreRobots, int clayRobots, int obsidianRobots, int geodeRobots, int&bestGeodes, std::string history){ |
|
|
|
|
for (;minute<32;minute++){ |
|
|
|
|
//Find out total robots needed for one geode robot.
|
|
|
|
|
//Geode: 2ore:19obsidian
|
|
|
|
|
//Obsidian 4ore:7clay
|
|
|
|
|
//Clay 4ore
|
|
|
|
|
//Ore 4ore
|
|
|
|
|
std::cout<<"Minute "<<i+1<<std::endl;
|
|
|
|
|
//std::cout<<" Minute "<<i+1<<std::endl;
|
|
|
|
|
|
|
|
|
|
//14ore:7clay:19obsidian 30
|
|
|
|
|
|
|
|
|
|
if (ore>=print.geodeRobotCost1&&obsidian>=print.geodeRobotCost2){ |
|
|
|
|
runSimulation(print,minute+1,ore-print.geodeRobotCost1+oreRobots,clay+clayRobots,obsidian-print.geodeRobotCost2+obsidianRobots,geodes+geodeRobots,oreRobots,clayRobots,obsidianRobots,geodeRobots+1,bestGeodes,history+"->GEO"); |
|
|
|
|
} else |
|
|
|
|
if (ore>=print.obsidianRobotCost1&&clay>=print.obsidianRobotCost2){ |
|
|
|
|
runSimulation(print,minute+1,ore-print.obsidianRobotCost1+oreRobots,clay-print.obsidianRobotCost2+clayRobots,obsidian+obsidianRobots,geodes+geodeRobots,oreRobots,clayRobots,obsidianRobots+1,geodeRobots,bestGeodes,history+"->OBS"); |
|
|
|
|
} else { |
|
|
|
|
if(ore>=print.oreRobotCost){ |
|
|
|
|
runSimulation(print,minute+1,ore-print.oreRobotCost+oreRobots,clay+clayRobots,obsidian+obsidianRobots,geodes+geodeRobots,oreRobots+1,clayRobots,obsidianRobots,geodeRobots,bestGeodes,history+"->ORE"); |
|
|
|
|
} |
|
|
|
|
if (ore>=print.clayRobotCost){ |
|
|
|
|
runSimulation(print,minute+1,ore-print.clayRobotCost+oreRobots,clay+clayRobots,obsidian+obsidianRobots,geodes+geodeRobots,oreRobots,clayRobots+1,obsidianRobots,geodeRobots,bestGeodes,history+"->CLA"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ore+=oreRobots; |
|
|
|
|
clay+=clayRobots; |
|
|
|
|
obsidian+=obsidianRobots; |
|
|
|
|
geodes+=geodeRobots; |
|
|
|
|
|
|
|
|
|
if (oreRobots>0){ |
|
|
|
|
std::cout<<"Collected "<<oreRobots<<" ore ("<<ore<<")."<<std::endl;
|
|
|
|
|
} |
|
|
|
|
if (clayRobots>0){ |
|
|
|
|
std::cout<<"Collected "<<clayRobots<<" clay ("<<clay<<")."<<std::endl;
|
|
|
|
|
} |
|
|
|
|
if (obsidianRobots>0){ |
|
|
|
|
std::cout<<"Collected "<<obsidianRobots<<" obsidian ("<<obsidian<<")."<<std::endl;
|
|
|
|
|
} |
|
|
|
|
if (geodeRobots>0){ |
|
|
|
|
std::cout<<"Collected "<<geodeRobots<<" geodes ("<<geodes<<")."<<std::endl;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int totalProduction=oreRobots+clayRobots+obsidianRobots+geodeRobots; |
|
|
|
|
|
|
|
|
|
orePct=(float)oreRobots/totalProduction; |
|
|
|
|
clayPct=(float)clayRobots/totalProduction; |
|
|
|
|
obsidianPct=(float)obsidianRobots/totalProduction; |
|
|
|
|
geodePct=(float)geodeRobots/totalProduction; |
|
|
|
|
|
|
|
|
|
std::cout<<"Resource distribution (Ore/Clay/Obsidian/Geode) ("<<orePct<<"/"<<clayPct<<"/"<<obsidianPct<<"/"<<geodePct<<")"<<std::endl; |
|
|
|
|
std::cout<<" Target distribution (Ore/Clay/Obsidian/Geode) ("<<oreRatio<<"/"<<clayRatio<<"/"<<obsidianRatio<<"/"<<geodeRatio<<")"<<std::endl; |
|
|
|
|
|
|
|
|
|
if (ore>=print.geodeRobotCost1&&obsidian>=print.geodeRobotCost2&&geodePct<geodeRatio){ |
|
|
|
|
geodeRobots++; |
|
|
|
|
ore-=print.geodeRobotCost1; |
|
|
|
|
obsidian-=print.geodeRobotCost2; |
|
|
|
|
std::cout<<" Built a geode robot ("<<geodeRobots<<" total)"<<std::endl;
|
|
|
|
|
} else |
|
|
|
|
if (ore>=print.obsidianRobotCost1&&clay>=print.obsidianRobotCost2&&obsidianPct<obsidianRatio){ |
|
|
|
|
//We can make an obsidian bot, so do so!
|
|
|
|
|
obsidianRobots++; |
|
|
|
|
ore-=print.obsidianRobotCost1; |
|
|
|
|
clay-=print.obsidianRobotCost2; |
|
|
|
|
std::cout<<" Built an obsidian robot ("<<obsidianRobots<<" total)"<<std::endl;
|
|
|
|
|
} else |
|
|
|
|
if(ore>=print.oreRobotCost&&orePct<oreRatio){ |
|
|
|
|
//Make an ore bot.
|
|
|
|
|
oreRobots++; |
|
|
|
|
ore-=print.oreRobotCost; |
|
|
|
|
std::cout<<" Built an ore robot ("<<oreRobots<<" total)"<<std::endl;
|
|
|
|
|
} else |
|
|
|
|
if (ore>=print.clayRobotCost&&clayPct<clayRatio){ |
|
|
|
|
//Make a clay bot.
|
|
|
|
|
clayRobots++; |
|
|
|
|
ore-=print.clayRobotCost; |
|
|
|
|
std::cout<<" Built a clay robot ("<<clayRobots<<" total)"<<std::endl;
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
std::cout<<" Decided not to make anything this turn..."<<std::endl;
|
|
|
|
|
} |
|
|
|
|
history+="->WAIT"; |
|
|
|
|
} |
|
|
|
|
if (geodes>bestGeodes){ |
|
|
|
|
bestGeodes=geodes; |
|
|
|
|
bestHistory=history; |
|
|
|
|
} |
|
|
|
|
return geodes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
@ -147,9 +116,15 @@ int main() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
int sum=0; |
|
|
|
|
for (int i=0;i<blueprints.size();i++){ |
|
|
|
|
sum+=(i+1)*runSimulation(blueprints[i]); |
|
|
|
|
for (int i=0;i<3;i++){ |
|
|
|
|
int highest=0; |
|
|
|
|
bestHistory=""; |
|
|
|
|
std::cout<<"Running Blueprint "<<i+1<<std::endl; |
|
|
|
|
runSimulation(blueprints[i],0,0,0,0,0,1,0,0,0,highest,""); |
|
|
|
|
sum+=(i+1)*highest; |
|
|
|
|
std::cout<<" Highest Geode Returns: "<<highest<<" ("<<bestHistory<<")"<<std::endl; |
|
|
|
|
} |
|
|
|
|
std::cout<<"Sum: "<<sum<<std::endl; |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|