#define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #include "olcutils.h" using namespace olc; struct Blueprint{ int oreRobotCost,clayRobotCost,obsidianRobotCost1,obsidianRobotCost2,geodeRobotCost1,geodeRobotCost2; }; enum Priority{ OREROBOT, CLAYROBOT, OBSIDIANROBOT, }; 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; } } std::string bestHistory=""; 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 "<=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; history+="->WAIT"; } if (geodes>bestGeodes){ bestGeodes=geodes; bestHistory=history; } } int main() { std::ifstream file("input"); std::vectorblueprints; while (file.good()){ std::string line; std::getline(file,line); std::cout<0){ Blueprint newBlueprint; int marker=0; for (int i=0;i<6;i++){ marker=line.find(' ',marker+1); } newBlueprint.oreRobotCost=std::atoi(line.substr(marker+1,line.find(' ',marker+1)-marker).c_str()); for (int i=0;i<6;i++){ marker=line.find(' ',marker+1); } newBlueprint.clayRobotCost=std::atoi(line.substr(marker+1,line.find(' ',marker+1)-marker).c_str()); for (int i=0;i<6;i++){ marker=line.find(' ',marker+1); } newBlueprint.obsidianRobotCost1=std::atoi(line.substr(marker+1,line.find(' ',marker+1)-marker).c_str()); for (int i=0;i<3;i++){ marker=line.find(' ',marker+1); } newBlueprint.obsidianRobotCost2=std::atoi(line.substr(marker+1,line.find(' ',marker+1)-marker).c_str()); for (int i=0;i<6;i++){ marker=line.find(' ',marker+1); } newBlueprint.geodeRobotCost1=std::atoi(line.substr(marker+1,line.find(' ',marker+1)-marker).c_str()); for (int i=0;i<3;i++){ marker=line.find(' ',marker+1); } newBlueprint.geodeRobotCost2=std::atoi(line.substr(marker+1,line.find(' ',marker+1)-marker).c_str()); std::cout<<"Blueprint "<