Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "stdafx.h"
- #include <iostream>
- #include <cmath>
- #include "stdio.h"
- #include <vector>
- #include <fstream>
- class FragmentOptimizationParameters {
- public:
- int minLevel;
- int levelDifference;
- FragmentOptimizationParameters(){
- minLevel = 0;
- levelDifference = 20;
- }
- FragmentOptimizationParameters(int _minLevel, int _levelDifference){
- minLevel = _minLevel;
- levelDifference = _levelDifference;
- }
- };
- class FragmentCostParameters {
- public:
- double multFactor;
- double subtractFactor;
- FragmentCostParameters(double _multFactor, double _subtractFactor){
- multFactor = _multFactor;
- subtractFactor = _subtractFactor;
- }
- FragmentCostParameters(){
- multFactor = .05;
- subtractFactor = 0;
- }
- };
- //function prototypes
- //various functions given by HCS
- long long int experience(long long int skillLevel, long long int duration);
- long long int goldcost (long long int skillLevel, long long int duration);
- long long int xpToAdvance (int compLevel);
- long long int time (double skillLevel, double duration, double composingLevel);
- int FragmentCost(double skillLevel, int duration);
- //summation formulas
- long long int goldcost (long long int skillLevel, long long int duration, long long int potions);
- long long int totalGoldSpent (long long int skillLevel, long long int duration, long long int potions);
- long long int xpTotal (int compLevel);
- void totalFragCost(int skillLevel, int numSkills, int duration);
- void regularTotalFragCost(int skillLevel, int duration);
- //analytics functions
- int bestXPGoldRatio (int* maxSkillLevels, int* maxNumSkills, int composingLevel);
- void xpInGold ();
- void xpInGoldwithFrags ();
- void xpInGoldwithFragsv2();
- void OptimizedFragCost(int skillLevel, int numSkills, int duration, FragmentOptimizationParameters FOP);
- void lowestWeightedFragCost(int skillLevel, int numSkills, int duration);
- int OptimizedSkillLevels(int skillLevel, int numSkills, int duration, FragmentOptimizationParameters FOP);
- using namespace std;
- //global variables
- int userMaxSkillLevel = 0;
- int userMaxNumSkills = 0;
- static int maxSkillLevels[] = {0,300, 405, 655, 705, 855, 1015};
- static int maxNumSkills[]= {0,2,3,4,4,5,6};
- static int fragmentGoldCosts[] = {3000,2000,10000,15000,30000,35000};
- unsigned int maxCompLevel = 0;
- unsigned int composingLevel = 0;
- //fixing my pointer problems
- int totalFragmentCost[7] = {0,0,0,0,0,0,0};
- int regularTotalFragmentCost[7] = {0,0,0,0,0,0,0};
- int optimizedFragmentUsage[7] = {0,0,0,0,0,0,0};
- int lowestWeightedFragmentCost[8] = {0,0,0,0,0,0,0,0};
- vector<FragmentOptimizationParameters> FOPs;
- vector<FragmentCostParameters> FCPs;
- int main(){
- cout << "Composing Calculator v 1.0.2.1" << endl;
- cout << "Functional to level 6 (inclusive). Further data is required for higher levels." << endl << endl;
- cout << "Made by aa0007." << endl;
- cout << "Additional thanks to Savanc and Undjuvion for providing data and assistance." << endl << endl;
- FOPs.push_back(FragmentOptimizationParameters(0,20));
- FOPs.push_back(FragmentOptimizationParameters(50,20));
- FOPs.push_back(FragmentOptimizationParameters(125,20));
- FOPs.push_back(FragmentOptimizationParameters(175,50));
- FOPs.push_back(FragmentOptimizationParameters(250,50));
- FOPs.push_back(FragmentOptimizationParameters(300,50));
- FCPs.push_back(FragmentCostParameters(.05, 0));
- FCPs.push_back(FragmentCostParameters(.05, 50));
- FCPs.push_back(FragmentCostParameters(.05, 125));
- FCPs.push_back(FragmentCostParameters(.02, 175));
- FCPs.push_back(FragmentCostParameters(.02, 250));
- FCPs.push_back(FragmentCostParameters(.02, 300));
- maxCompLevel = sizeof(maxSkillLevels)/sizeof(int);
- do{
- cout << "Please enter your composing level: ";
- cin >> composingLevel;
- } while (composingLevel >= maxCompLevel || composingLevel < 1);
- userMaxNumSkills = maxNumSkills[composingLevel];
- userMaxSkillLevel = maxSkillLevels[composingLevel];
- cout << endl;
- cout << "Your max skill level is " << userMaxSkillLevel << endl;
- cout << "Your max num skills is " << userMaxNumSkills << endl;
- cout << endl;
- cout << "The current fragment values are as follows: " << endl;
- cout << "Common: " << fragmentGoldCosts[0] << endl;
- cout << "Rare: " << fragmentGoldCosts[1] << endl;
- cout << "Unique: " << fragmentGoldCosts[2] << endl;
- cout << "Legendary: " << fragmentGoldCosts[3] << endl;
- cout << "Crystalline: " << fragmentGoldCosts[4] << endl;
- cout << "Super Elite: " << fragmentGoldCosts[5] << endl;
- cout << "Press 'y' to move on or 'n' to change [ADVANCED USERS ONLY]: ";
- char temp;
- do {
- cin >> temp;
- cout << endl;
- if (temp == 'n'){
- cout << "Please enter your desired value: " << endl;
- cout << "Common: "; cin >> fragmentGoldCosts[0];
- cout << "Rare: "; cin >> fragmentGoldCosts[1];
- cout << "Unique: "; cin >> fragmentGoldCosts[2];
- cout << "Legendary: "; cin >> fragmentGoldCosts[3];
- cout << "Crystalline: "; cin >> fragmentGoldCosts[4];
- cout << "Super Elite: "; cin >> fragmentGoldCosts[5];
- cout << "Press 'y' to move on or 'n' to change [ADVANCED USERS ONLY]: ";
- }
- } while (temp != 'y');
- temp = 'a';
- bestXPGoldRatio(maxSkillLevels, maxNumSkills, composingLevel);
- do{
- xpInGoldwithFragsv2(); //gives optimized values
- cout << "Press 'y' to repeat or 'n' to quit" << endl;
- cin >> temp;
- } while (temp == 'y');
- //both functions have been rendered useless since they give the same results
- // xpInGold(); //useful when you've gotten free frags or care more for gold than frags
- // xpInGoldwithFrags(); //useful everywhere else
- //system("PAUSE");
- return 0;
- }
- //total skill leve and duration -> experience
- long long int experience (long long int skillLevel, long long int duration){
- return (long long int)(ceil((double)min(skillLevel,duration)/60 + (double)skillLevel/500)*10);
- }
- //total skill leve and duration -> gold cost
- long long int goldcost (long long int skillLevel,long long int duration){
- return (long long int)((skillLevel*duration)<5000?5000:skillLevel*duration);
- }
- //individual gold cost * 2^n for instant
- long long int goldcost (long long int skillLevel, long long int duration, long long int potions){
- return (long long int)(goldcost(skillLevel, duration) * pow(2,potions));
- }
- //actual gold cost for making n potions instantly
- long long int totalGoldSpent (long long int skillLevel, long long int duration, long long int potions){
- long long int totalGold = 0;
- for (int i = 0; i < potions; i++){
- totalGold += goldcost(skillLevel, duration, i);
- }
- return totalGold;
- }
- //total experience at any level
- long long int xpTotal (int compLevel){
- long long int xp = 0;
- while (compLevel > 0){
- xp += (250 + (compLevel-1)*500);
- compLevel--;
- }
- return xp;
- }
- //xp needed to progress to next level
- long long int xpToAdvance (int compLevel){
- return (250 + (compLevel-1)*500);
- }
- //time it takes to normal brew a potion
- long long int time (double skillLevel, double duration, double composingLevel){
- return (( (max( ((ceil(max(skillLevel,150.0)/20.0)*5) + (ceil(duration/30.0)*30)) - ((composingLevel-1)*5.0), 60.0)) ));
- }
- //shows the best xp/time ratio at all composing levels, prioritizing xp/time then gold cost
- int bestXPGoldRatio (int* maxSkillLevels, int* maxNumSkills, int currComposingLevel){
- int totalPotsMade = 0;
- int totaltime = 0;
- int composingLevel = 1;
- while (composingLevel <= currComposingLevel){
- double maximum=0;
- int mx=0;
- int my=0;
- long long int cost = 10000000000;
- for(double x=1; x<=maxSkillLevels[composingLevel]; x++)
- {
- for(double y=30; y<=300; y++)
- {
- double d=(ceil(min(x,y)/60.0 + x/500.0) * 10)/(( (max( ((ceil(max(x,150.0)/20.0)*5) + (ceil(y/30.0)*30)) - ((composingLevel-1)*5.0), 60.0)) ));
- if(d>maximum || d== maximum && goldcost(x,y)<cost)
- {
- maximum=d;
- mx=x;
- my=y;
- cost = goldcost(x,y);
- }
- }
- }
- cout << "Composing: " << composingLevel << ", XP/min: " << maximum << ", Skill: " << mx << ", Dur: " << my << ", Gold: " << cost << ", Pots: " << ceil((double)xpToAdvance(composingLevel)/(double)experience(mx,my)) << endl;
- totaltime+= time(mx,my,composingLevel)*(ceil((double)xpToAdvance(composingLevel)/(double)experience(mx,my)));
- totalPotsMade+= (ceil((double)xpToAdvance(composingLevel)/(double)experience(mx,my)) );
- composingLevel++;
- }
- //cout << endl << "Total Time: " << totaltime << ", Total Potions: " << totalPotsMade << endl;
- return 0;
- }
- //most xp in how much gold, not including fragment cost
- void xpInGold (){
- vector<long long int> optimalCosts;
- vector<long long int> skillLevels;
- vector<long long int> durations;
- unsigned int currentSize = 0;
- cout << endl;
- cout << "Optimal Potions based on Gold Cost Only" << endl;
- for (int i = 1; i <= userMaxSkillLevel; i++){
- for (int j = 30; j <= 300; j++){
- long long int currexp = experience(i,j)/10;
- if (currexp > optimalCosts.size()){
- optimalCosts.resize(currexp);
- skillLevels.resize(currexp);
- durations.resize(currexp);
- for (unsigned int a = currentSize; a < currexp; a++){
- optimalCosts[a] = 12386124718;
- }
- currentSize = optimalCosts.size();
- }
- if (goldcost(i,j) < optimalCosts[currexp-1]){
- optimalCosts[currexp-1] = goldcost(i,j);
- skillLevels[currexp-1] = i;
- durations[currexp-1] = j;
- }
- }
- }
- //prints vector
- for (int i = 0; i < optimalCosts.size(); i++){
- cout << (i+1)*10 << " xp, " << optimalCosts[i]<< " gold, " << skillLevels[i] << " skill levels, " << durations[i] << " minutes" << endl;
- }
- long long int gold = 0;
- cout << endl;
- cout << "Please enter the amount of gold you wish to spend: ";
- cin >> gold;
- cout << endl;
- long long int potions = 0;
- int xp=0;
- long long int goldSpent = 0;
- vector<int> potionsToMake;
- vector<int> bestPotionsToMake;
- int currentexp = 0;
- while(optimalCosts.size()>0){
- long long int tempgold = gold;
- long long int tempgoldspent = 0;
- for (int i = optimalCosts.size()-1; i >=0; i--){
- while (tempgold -optimalCosts[i]*pow(2,potions) >=0){
- tempgold -= optimalCosts[i]*pow(2,potions) + goldcost(skillLevels[i],durations[i]);
- tempgoldspent += optimalCosts[i]*pow(2,potions) + goldcost(skillLevels[i],durations[i]);
- potions++;
- currentexp += i*10+10;
- potionsToMake.push_back(i*10+10);
- }
- }
- optimalCosts.pop_back();
- if (currentexp > xp){
- bestPotionsToMake = potionsToMake;
- xp = currentexp;
- goldSpent = tempgoldspent;
- }
- else if (xp == currentexp && tempgoldspent < goldSpent){
- bestPotionsToMake = potionsToMake;
- xp = currentexp;
- goldSpent = tempgoldspent;
- }
- tempgoldspent = 0;
- potionsToMake.clear();
- currentexp = 0;
- potions = 0;
- }
- for (int i = 0; i < bestPotionsToMake.size(); i++){
- cout << "Potion " << i+1 << ": " << bestPotionsToMake[i] << endl;
- }
- cout << endl;
- cout << "Number of Potions to Make: " << bestPotionsToMake.size() << endl;
- cout << "Total XP Gained: " << xp << endl;
- cout << "Total Gold Spent " << goldSpent << endl;
- return;
- }
- void xpInGoldwithFragsv2(){
- vector<long long int> optimalCosts;
- vector<long long int> skillLevels;
- vector<long long int> durations;
- unsigned int currentSize = 0;
- cout << endl;
- cout << "Best way to instant compose with best frag usage" << endl;
- for (int i = 1; i <= userMaxSkillLevel; i++){
- for (int j = 30; j <= 300; j++){
- long long int currexp = experience(i,j)/10;
- if (currexp > optimalCosts.size()){
- optimalCosts.resize(currexp);
- skillLevels.resize(currexp);
- durations.resize(currexp);
- for (unsigned int a = currentSize; a < currexp; a++){
- optimalCosts[a] = 12386124718;
- }
- currentSize = optimalCosts.size();
- }
- if (goldcost(i,j) < optimalCosts[currexp-1]){
- optimalCosts[currexp-1] = goldcost(i,j);
- skillLevels[currexp-1] = i;
- durations[currexp-1] = j;
- }
- }
- }
- for (int i = 0; i < optimalCosts.size(); i++){
- cout << (i+1)*10 << " xp, Fragments: ";
- for (int j = 0; j < 7; j++){
- lowestWeightedFragCost(skillLevels[i], userMaxNumSkills, durations[i]);
- cout << lowestWeightedFragmentCost[j+1]<< ", ";
- }
- cout << optimalCosts[i]<< " Gold, " << skillLevels[i] << " Level, " << durations[i] << " Min, " << endl;
- cout << " Potion Levels: ";
- lowestWeightedFragCost(skillLevels[i], userMaxNumSkills, durations[i]);
- OptimizedSkillLevels(skillLevels[i], userMaxNumSkills, durations[i], FOPs[lowestWeightedFragmentCost[0]]);
- cout << endl << endl;
- }
- long long int gold = 0;
- cout << endl;
- cout << "Please enter the amount of gold you wish to spend: ";
- cin >> gold;
- cout << endl;
- long long int potions = 0;
- int xp=0;
- long long int goldSpent = 0;
- //figure out which are the best potions to make based on the gold cost, don't need to worry about fragments
- vector<int> potionsToMake;
- vector<int> bestPotionsToMake;
- int currentexp = 0;
- while(optimalCosts.size()>0){
- long long int tempgold = gold;
- long long int tempgoldspent = 0;
- for (int i = optimalCosts.size()-1; i >=0; i--){
- while (tempgold -optimalCosts[i]*pow(2,potions) >=0){
- tempgold -= optimalCosts[i]*pow(2,potions) + goldcost(skillLevels[i],durations[i]);
- tempgoldspent += optimalCosts[i]*pow(2,potions) + goldcost(skillLevels[i],durations[i]);
- potions++;
- currentexp += i*10+10;
- potionsToMake.push_back(i*10+10);
- }
- }
- optimalCosts.pop_back();
- if (currentexp > xp){
- bestPotionsToMake = potionsToMake;
- xp = currentexp;
- goldSpent = tempgoldspent;
- }
- else if (xp == currentexp && tempgoldspent < goldSpent){
- bestPotionsToMake = potionsToMake;
- xp = currentexp;
- goldSpent = tempgoldspent;
- }
- tempgoldspent = 0;
- potionsToMake.clear();
- currentexp = 0;
- potions = 0;
- }
- int frags[] = {0,0,0,0,0,0,0};
- for (int i = 0; i < bestPotionsToMake.size(); i++){
- for (int j = 0; j < sizeof(frags)/sizeof(int); j++){
- lowestWeightedFragCost(skillLevels[(bestPotionsToMake[i]-10)/10], userMaxNumSkills, durations[(bestPotionsToMake[i]-10)/10]);
- frags[j] += lowestWeightedFragmentCost[j+1];
- }
- }
- for (int i = 0; i < bestPotionsToMake.size(); i++){
- cout << "Potion " << i+1 << ": " << bestPotionsToMake[i] << endl;
- }
- cout << endl;
- cout << "Number of Potions to Make: " << bestPotionsToMake.size() << endl;
- cout << "Total XP Gained: " << xp << endl;
- cout << "Total Gold Spent: " << goldSpent << endl;
- cout << "Total Fragments Used: " << frags[0] << endl;
- cout << "Total Common Fragments Used: " << frags[1] << endl;
- cout << "Total Rare Fragments Used: " << frags[2] << endl;
- cout << "Total Unique Fragments Used: " << frags[3] << endl;
- cout << "Total Legendary Fragments Used: " << frags[4] << endl;
- cout << "Total Crystalline Fragments Used: " << frags[5] << endl;
- cout << "Total Super Elite Fragments Used: " << frags[6] << endl;
- cout << endl;
- return;
- }
- //best XP considering fragments
- void xpInGoldwithFrags (){
- unsigned int skillMax = userMaxSkillLevel;
- unsigned int skillNumMax = userMaxNumSkills;
- vector<long long int> optimalCosts;
- vector<long long int> optimalFragCosts;
- vector<long long int> skillLevels;
- vector<long long int> durations;
- unsigned int currentSize = 0;
- cout << endl;
- cout << "Optimal Potions with Best Gold and Fragment Usage" << endl;
- cout << endl;
- for (int i = 1; i <= skillMax; i++){
- for (int j = 30; j <= 300; j++){ //through duration
- long long int currexp = experience(i,j)/10;
- if (currexp > optimalCosts.size()){
- optimalFragCosts.resize(currexp);
- optimalCosts.resize(currexp);
- skillLevels.resize(currexp);
- durations.resize(currexp);
- for (unsigned int a = currentSize; a < currexp; a++){
- optimalFragCosts[a] = 12386124718;
- }
- currentSize = optimalFragCosts.size();
- }
- lowestWeightedFragCost(i,skillNumMax, j);
- if (lowestWeightedFragmentCost[0] < optimalFragCosts[currexp-1]){
- optimalFragCosts[currexp-1] = lowestWeightedFragmentCost[0];
- optimalCosts[currexp-1] = goldcost(i,j);
- skillLevels[currexp-1] = i;
- durations[currexp-1] = j;
- }
- }
- }
- //prints vector
- for (int i = 0; i < optimalFragCosts.size(); i++){
- cout << (i+1)*10 << " xp, Fragments: ";
- for (int j = 0; j < 7; j++){
- lowestWeightedFragCost(skillLevels[i], skillNumMax, durations[i]);
- cout << lowestWeightedFragmentCost[j+1]<< ", ";
- }
- cout << optimalCosts[i]<< " gold, " << skillLevels[i] << " levels, " << durations[i] << " min" << endl;
- }
- long long int gold = 0;
- cout << endl;
- cout << "Please enter the amount of gold you wish to spend: ";
- cin >> gold;
- cout << endl;
- long long int potions = 0;
- int xp=0;
- long long int goldSpent = 0;
- int tempfrags[7] = {0,0,0,0,0,0,0};
- int frags[7] = {0,0,0,0,0,0,0};
- vector<int> potionsToMake;
- vector<int> bestPotionsToMake;
- int currentexp = 0;
- while(optimalCosts.size()>0){
- long long int tempgold = gold;
- long long int tempgoldspent = 0;
- for (int i = optimalCosts.size()-1; i >=0; i--){
- while (tempgold -(optimalCosts[i]*pow(2,potions) +goldcost(skillLevels[i],durations[i])) >=0){
- tempgold -= (optimalCosts[i]*pow(2,potions) + goldcost(skillLevels[i],durations[i]));
- tempgoldspent += (optimalCosts[i]*pow(2,potions) + goldcost(skillLevels[i],durations[i]));
- potions++;
- currentexp += i*10+10;
- potionsToMake.push_back(i*10+10);
- for (int q = 0; q < 7; q++){
- totalFragCost(skillLevels[i], skillNumMax, durations[i]);
- tempfrags[q] += totalFragmentCost[q];
- }
- }
- }
- optimalCosts.pop_back();
- if (currentexp > xp){
- bestPotionsToMake = potionsToMake;
- xp = currentexp;
- goldSpent = tempgoldspent;
- for (int q = 0; q < 7; q++){
- frags[q] = tempfrags[q];
- }
- }
- else if (xp == currentexp && tempgoldspent < goldSpent){
- bestPotionsToMake = potionsToMake;
- xp = currentexp;
- goldSpent = tempgoldspent;
- for (int q = 0; q < 7; q++){
- frags[q] = tempfrags[q];
- }
- }
- tempgoldspent = 0;
- potionsToMake.clear();
- currentexp = 0;
- potions = 0;
- for (int q = 0; q < 7; q++){
- tempfrags[q] = 0;
- }
- }
- for (int i = 0; i < bestPotionsToMake.size(); i++){
- cout << "Potion " << i << ": " << bestPotionsToMake[i] << endl;
- }
- cout << endl;
- cout << "Number of Potions to Make: " << bestPotionsToMake.size() << endl;
- cout << "Total XP Gained: " << xp << endl;
- cout << "Total Gold Spent: " << goldSpent << endl;
- cout << "Total Fragments Used: " << frags[0] << endl;
- cout << "Total Common Fragments Used: " << frags[1] << endl;
- cout << "Total Rare Fragments Used: " << frags[2] << endl;
- cout << "Total Unique Fragments Used: " << frags[3] << endl;
- cout << "Total Legendary Fragments Used: " << frags[4] << endl;
- cout << "Total Crystalline Fragments Used: " << frags[5] << endl;
- cout << "Total Super Elite Fragments Used: " << frags[6] << endl;
- cout << endl;
- return;
- }
- //fragment cost based on which parameters you use
- int FragmentCost(double skillLevel, int duration, FragmentCostParameters FCP){
- return max((int)(ceil(FCP.multFactor*(skillLevel-FCP.subtractFactor))*ceil(duration/30.0)) , 0);
- }
- //total frag cost assuming that each skill is divided evenly. NOT the most efficient skill max.
- void totalFragCost(int skillLevel, int numSkills, int duration){
- for (int i = 0; i < 7 ; i++){
- totalFragmentCost[i] = 0;
- }
- while (skillLevel > 0 && numSkills > 0){
- int tempSkill = ceil((double)skillLevel/(double)numSkills);
- totalFragmentCost[0]+= FragmentCost(tempSkill,duration, FCPs[0]);
- totalFragmentCost[1]+= FragmentCost(tempSkill,duration, FCPs[0]);
- totalFragmentCost[0]+= FragmentCost(tempSkill,duration, FCPs[1]);
- totalFragmentCost[2]+= FragmentCost(tempSkill,duration, FCPs[1]);
- totalFragmentCost[0]+= FragmentCost(tempSkill,duration, FCPs[2]);
- totalFragmentCost[3]+= FragmentCost(tempSkill,duration, FCPs[2]);
- totalFragmentCost[0]+= FragmentCost(tempSkill,duration, FCPs[3]);
- totalFragmentCost[4]+= FragmentCost(tempSkill,duration, FCPs[3]);
- totalFragmentCost[0]+= FragmentCost(tempSkill,duration, FCPs[4]);
- totalFragmentCost[5]+= FragmentCost(tempSkill,duration, FCPs[4]);
- totalFragmentCost[0]+= FragmentCost(tempSkill,duration, FCPs[5]);
- totalFragmentCost[6]+= FragmentCost(tempSkill,duration, FCPs[5]);
- skillLevel -= ceil((double)skillLevel/(double)numSkills);
- numSkills--;
- }
- return;
- }
- //given a skill level + duration, will return an array with the fragment usage
- void regularTotalFragCost(int skillLevel, int duration){
- for (int i = 0; i < 7; i++){
- regularTotalFragmentCost[i] = 0;
- }
- regularTotalFragmentCost[0]+= FragmentCost(skillLevel,duration, FCPs[0]);
- regularTotalFragmentCost[1]+= FragmentCost(skillLevel,duration, FCPs[0]);
- regularTotalFragmentCost[0]+= FragmentCost(skillLevel,duration, FCPs[1]);
- regularTotalFragmentCost[2]+= FragmentCost(skillLevel,duration, FCPs[1]);
- regularTotalFragmentCost[0]+= FragmentCost(skillLevel,duration, FCPs[2]);
- regularTotalFragmentCost[3]+= FragmentCost(skillLevel,duration, FCPs[2]);
- regularTotalFragmentCost[0]+= FragmentCost(skillLevel,duration, FCPs[3]);
- regularTotalFragmentCost[4]+= FragmentCost(skillLevel,duration, FCPs[3]);
- regularTotalFragmentCost[0]+= FragmentCost(skillLevel,duration, FCPs[4]);
- regularTotalFragmentCost[5]+= FragmentCost(skillLevel,duration, FCPs[4]);
- regularTotalFragmentCost[0]+= FragmentCost(skillLevel,duration, FCPs[5]);
- regularTotalFragmentCost[6]+= FragmentCost(skillLevel,duration, FCPs[5]);
- return;
- }
- //optimizes for a single fragment tier
- void OptimizedFragCost(int skillLevel, int numSkills, int duration, FragmentOptimizationParameters FOP){
- for (int i = 0; i < 7; i++){
- optimizedFragmentUsage[i] = 0;
- }
- vector<int> fragCutoffs;
- int increment = 1;
- int tempSkillLevel = skillLevel;
- while (tempSkillLevel>FOP.minLevel){
- fragCutoffs.push_back(increment*20 + FOP.minLevel);
- increment++;
- tempSkillLevel-= 20;
- }
- if (fragCutoffs.size() > 0)
- fragCutoffs.pop_back();
- vector<int> skills(numSkills); //can't have more skills than the max num of skills
- if (fragCutoffs.size() == 0){
- skills.clear();
- skills.push_back(skillLevel);
- }
- else {
- int highestSkillLevel = FOP.minLevel;
- double average = (double)skillLevel/(double)numSkills;
- for (int i = fragCutoffs.size()-1; i >= 0; i--){
- if (fragCutoffs[i] <= average){
- highestSkillLevel = fragCutoffs[i];
- break;
- }
- }
- int j = 0;
- int skillsdone = 0;
- while (skillLevel > highestSkillLevel&& skillsdone < numSkills){
- if (highestSkillLevel < skillLevel){
- skills[j] = highestSkillLevel;
- skillLevel-= highestSkillLevel;
- skillsdone++;
- }
- j++;
- }
- //just adds the remainder to the last skill
- int skillIncrement = 0;
- while (skillLevel > FOP.levelDifference){
- skills[skillIncrement%numSkills] += FOP.levelDifference;
- skillLevel-= FOP.levelDifference;
- skillIncrement++;
- }
- skills[skills.size()-1] += skillLevel;
- }
- for (int i = 0; i < skills.size(); i++){
- for (int j = 0; j < 7; j++){
- regularTotalFragCost(skills[i], duration);
- optimizedFragmentUsage[j] += regularTotalFragmentCost[j];
- }
- }
- return;
- }
- //finally got it working
- int OptimizedSkillLevels(int skillLevel, int numSkills, int duration, FragmentOptimizationParameters FOP){
- vector<int> fragCutoffs;
- int increment = 1;
- int tempSkillLevel = skillLevel;
- while (tempSkillLevel>FOP.minLevel){
- fragCutoffs.push_back(increment*20 + FOP.minLevel);
- increment++;
- tempSkillLevel-= 20;
- }
- if (fragCutoffs.size() > 0)
- fragCutoffs.pop_back();
- vector<int> skills(numSkills); //can't have more skills than the max num of skills
- if (fragCutoffs.size() == 0){
- skills.clear();
- skills.push_back(skillLevel);
- }
- else {
- int highestSkillLevel = FOP.minLevel;
- double average = (double)skillLevel/(double)numSkills;
- for (int i = fragCutoffs.size()-1; i >= 0; i--){
- if (fragCutoffs[i] <= average){
- highestSkillLevel = fragCutoffs[i];
- break;
- }
- }
- int j = 0;
- int skillsdone = 0;
- while (skillLevel > highestSkillLevel&& skillsdone < numSkills){
- if (highestSkillLevel < skillLevel){
- skills[j] = highestSkillLevel;
- skillLevel-= highestSkillLevel;
- skillsdone++;
- }
- j++;
- }
- //just adds the remainder to the last skill
- int skillIncrement = 0;
- while (skillLevel > FOP.levelDifference){
- skills[skillIncrement%numSkills] += FOP.levelDifference;
- skillLevel-= FOP.levelDifference;
- skillIncrement++;
- }
- skills[skills.size()-1] += skillLevel;
- }
- for (int i = 0; i < skills.size(); i++){
- cout << skills[i] << ", ";
- }
- return 0;
- }
- //finds the lowest gold cost of all of the fragment optimizations
- void lowestWeightedFragCost(int skillLevel, int numSkills, int duration){
- for (int i = 0; i < 8; i++){
- lowestWeightedFragmentCost[i] = 0;
- }
- int tempGoldCost = 0;
- int leastGoldCost = 999999999;
- int leastGoldCostIndex = 10;
- for (int i = 0; i < FOPs.size(); i++){
- for (int j = 0; j < 6; j++){
- OptimizedFragCost(skillLevel, numSkills, duration, FOPs[i]);
- tempGoldCost += optimizedFragmentUsage[j+1]*fragmentGoldCosts[j];
- }
- if (tempGoldCost < leastGoldCost){
- leastGoldCost = tempGoldCost;
- leastGoldCostIndex = i;
- }
- }
- lowestWeightedFragmentCost[0] = leastGoldCostIndex;
- for (int i = 0; i < sizeof(lowestWeightedFragmentCost)/sizeof(int) - 1; i++){
- OptimizedFragCost(skillLevel, numSkills, duration, FOPs[leastGoldCostIndex]);
- lowestWeightedFragmentCost[i+1] = optimizedFragmentUsage[i];
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement