diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index 5bcae5ed1..a417108cb 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -358,4 +358,5 @@ Revision Log Message 351 352 353 -354 Unlanded countries inherit tech group from holder of their potential capital \ No newline at end of file +354 Unlanded countries inherit tech group from holder of their potential capital +355 Add second method of tech group conversion \ No newline at end of file diff --git a/Data Files/configuration.txt b/Data Files/configuration.txt index 5aa686a2d..269e3e836 100644 --- a/Data Files/configuration.txt +++ b/Data Files/configuration.txt @@ -7,6 +7,13 @@ configuration = CK2directory = "D:\Paradox Interactive\Crusader Kings II" + ### Tech Options + + # techGroupMethod: the method by which tech groups are determined. Options are: + # "learningRate" - use the CK2 learning rate to determine tech groups + # "culturalTech" - use the amount of tech gained in CK2, broken down by relious and culture groups, to determine tech. NOTE: do not use this option along with mods, as it relies heavily on default religions and cultures + techGroupMethod = "learningRate" + ### Economy (base tax, manpower, and population) Options diff --git a/Source/Configuration.cpp b/Source/Configuration.cpp index 04299a1ef..5fec06091 100644 --- a/Source/Configuration.cpp +++ b/Source/Configuration.cpp @@ -33,17 +33,20 @@ Configuration::Configuration() CK2Path = obj[0]->getLeaf("CK2directory"); EU3Path = obj[0]->getLeaf("EU3directory"); - proxyMultiplierMethod = obj[0]->getLeaf("proxyMultiplierMethod"); - multipleProvsMethod = obj[0]->getLeaf("multipleProvsMethod"); - manpower = obj[0]->getLeaf("manpower"); + + techGroupMethod = obj[0]->getLeaf("techGroupMethod"); + + proxyMultiplierMethod = obj[0]->getLeaf("proxyMultiplierMethod"); + multipleProvsMethod = obj[0]->getLeaf("multipleProvsMethod"); + manpower = obj[0]->getLeaf("manpower"); manpowerblendamount = obj[0]->getLeaf("manpowerblendamount"); - basetax = obj[0]->getLeaf("basetax"); + basetax = obj[0]->getLeaf("basetax"); basetaxblendamount = obj[0]->getLeaf("basetaxblendamount"); - population = obj[0]->getLeaf("population"); + population = obj[0]->getLeaf("population"); populationblendamount = obj[0]->getLeaf("populationblendamount"); - HRETitle = obj[0]->getLeaf("HRETitle"); - mergeTitles = obj[0]->getLeaf("mergeTitles"); - vassalScore = obj[0]->getLeaf("vassalScore"); + HRETitle = obj[0]->getLeaf("HRETitle"); + mergeTitles = obj[0]->getLeaf("mergeTitles"); + vassalScore = obj[0]->getLeaf("vassalScore"); advisors = obj[0]->getLeaf("advisors"); leaders = obj[0]->getLeaf("leaders"); diff --git a/Source/Configuration.h b/Source/Configuration.h index 3797072cd..40f96f10f 100644 --- a/Source/Configuration.h +++ b/Source/Configuration.h @@ -22,6 +22,11 @@ class Configuration // Singleton return getInstance()->EU3Path; } + static string getTechGroupMethod() + { + return getInstance()->techGroupMethod; + } + static string getProxyMultiplierMethod() { return getInstance()->proxyMultiplierMethod; @@ -160,6 +165,9 @@ class Configuration // Singleton string CK2Path; string EU3Path; + + string techGroupMethod; + string proxyMultiplierMethod; string multipleProvsMethod; string manpower; diff --git a/Source/EU3World/EU3Country.cpp b/Source/EU3World/EU3Country.cpp index b7c32a89f..e21d4866e 100644 --- a/Source/EU3World/EU3Country.cpp +++ b/Source/EU3World/EU3Country.cpp @@ -732,6 +732,27 @@ void EU3Country::determineLearningScore() learningScore /= numBaronies; } +void EU3Country::determineTechScore() +{ + int numProvinces = 0; + for (vector::iterator provinceItr = provinces.begin(); provinceItr < provinces.end(); provinceItr++) + { + vector srcProvinces = (*provinceItr)->getSrcProvinces(); + for (vector::iterator srcItr = srcProvinces.begin(); srcItr < srcProvinces.end(); srcItr++) + { + vector techLevels = (*srcItr)->getTechLevels(); + for (unsigned int i = 0; i < techLevels.size(); i++) + { + techScore += techLevels[i] / 24; + } + numProvinces++; + } + } + + techScore /= numProvinces; +} + + void EU3Country::addAcceptedCultures() { diff --git a/Source/EU3World/EU3Country.h b/Source/EU3World/EU3Country.h index d76879638..c4d87a08f 100644 --- a/Source/EU3World/EU3Country.h +++ b/Source/EU3World/EU3Country.h @@ -30,6 +30,7 @@ class EU3Country void output(FILE*); void determineLearningScore(); + void determineTechScore(); void addAcceptedCultures(); void determineGovernment(double prestigeFactor); void determineEconomy(const cultureGroupMapping& cultureGroups, const map& unitPrices); @@ -61,6 +62,7 @@ class EU3Country vector getCores() const { return cores; }; vector getAdvisors() const { return advisors; }; double getLearningScore() const { return learningScore; }; + double getTechScore() const { return techScore; }; int getAbsorbScore() const { return absorbScore; }; string getTag() const { return tag; }; string getGovernment() const { return government; }; @@ -82,6 +84,7 @@ class EU3Country vector cores; vector advisors; double learningScore; + double techScore; int absorbScore; string tag; diff --git a/Source/EU3World/EU3World.cpp b/Source/EU3World/EU3World.cpp index 81c79bdf8..097d6e959 100644 --- a/Source/EU3World/EU3World.cpp +++ b/Source/EU3World/EU3World.cpp @@ -796,80 +796,321 @@ void EU3World::convertAdvisors(inverseProvinceMapping& inverseProvinceMap, provi _findclose(fileListing); } -#pragma optimize("",off) + void EU3World::convertTech(const CK2World& srcWorld) { - vector avgTechLevels = srcWorld.getAverageTechLevels(); - - vector unlandedCountries; - double highestLearningScore = 0.0f; - for (vector::iterator countryItr = convertedCountries.begin(); countryItr != convertedCountries.end(); countryItr++) + if (Configuration::getTechGroupMethod() == "learningRate") { - if ((*countryItr)->getProvinces().size() > 0) + vector avgTechLevels = srcWorld.getAverageTechLevels(); + + vector unlandedCountries; + double highestLearningScore = 0.0f; + for (vector::iterator countryItr = convertedCountries.begin(); countryItr != convertedCountries.end(); countryItr++) { - (*countryItr)->determineLearningScore(); - if ((*countryItr)->getLearningScore() > highestLearningScore) + if ((*countryItr)->getProvinces().size() > 0) { - highestLearningScore = (*countryItr)->getLearningScore(); + (*countryItr)->determineLearningScore(); + if ((*countryItr)->getLearningScore() > highestLearningScore) + { + highestLearningScore = (*countryItr)->getLearningScore(); + } + } + else + { + unlandedCountries.push_back(*countryItr); } } - else - { - unlandedCountries.push_back(*countryItr); - } - } - log("Highest tech score is %f\n", highestLearningScore); - for (vector::iterator countryItr = convertedCountries.begin(); countryItr != convertedCountries.end(); countryItr++) - { - CK2Religion* religion = (*countryItr)->getSrcCountry()->getLastHolder()->getReligion(); - string title = (*countryItr)->getSrcCountry()->getTitleString(); - if ( ( (title == "e_golden_horde") || (title == "e_il-khanate") || (title == "e_timurids") ) && (religion->getGroup() != "christian") ) + log("Highest tech score is %f\n", highestLearningScore); + for (vector::iterator countryItr = convertedCountries.begin(); countryItr != convertedCountries.end(); countryItr++) { - (*countryItr)->setTechGroup("nomad_group"); - } - else if ((*countryItr)->getLearningScore() <= 0.23 * highestLearningScore) - { - (*countryItr)->setTechGroup("muslim"); - } - else if ((*countryItr)->getLearningScore() <= 0.28 * highestLearningScore) - { - (*countryItr)->setTechGroup("ottoman"); + if ((*countryItr)->getProvinces().size() <= 0) + { + continue; + } + CK2Religion* religion = (*countryItr)->getSrcCountry()->getLastHolder()->getReligion(); + string title = (*countryItr)->getSrcCountry()->getTitleString(); + if ( ( (title == "e_golden_horde") || (title == "e_il-khanate") || (title == "e_timurids") ) && (religion->getGroup() != "christian") ) + { + (*countryItr)->setTechGroup("nomad_group"); + } + else if ((*countryItr)->getLearningScore() <= 0.23 * highestLearningScore) + { + (*countryItr)->setTechGroup("muslim"); + } + else if ((*countryItr)->getLearningScore() <= 0.28 * highestLearningScore) + { + (*countryItr)->setTechGroup("ottoman"); + } + else if ((*countryItr)->getLearningScore() <= 0.48 * highestLearningScore) + { + (*countryItr)->setTechGroup("eastern"); + } + else + { + (*countryItr)->setTechGroup("western"); + } + log("\t,%s,%f,%s\n", (*countryItr)->getTag().c_str(), (*countryItr)->getLearningScore(), (*countryItr)->getTechGroup().c_str()); + + (*countryItr)->determineTechLevels(avgTechLevels, techData); } - else if ((*countryItr)->getLearningScore() <= 0.48 * highestLearningScore) + for (vector::iterator countryItr = unlandedCountries.begin(); countryItr != unlandedCountries.end(); countryItr++) { - (*countryItr)->setTechGroup("eastern"); + map::iterator capitalItr = provinces.find( (*countryItr)->getCapital() ); + if (capitalItr != provinces.end()) + { + (*countryItr)->setTechGroup( capitalItr->second->getOwner()->getTechGroup() ); + } + else + { + (*countryItr)->setTechGroup("western"); + log("\tWarning: %s had no capital, defaulting tech group to western\n", (*countryItr)->getTag().c_str()); + } + (*countryItr)->determineTechLevels(avgTechLevels, techData); + log("\t,%s,%f,%s\n", (*countryItr)->getTag().c_str(), 0.0F, (*countryItr)->getTechGroup().c_str()); } - else + + for(map::iterator countryItr = countries.begin(); countryItr != countries.end(); countryItr++) { - (*countryItr)->setTechGroup("western"); + countryItr->second->determineTechInvestment(techData, startDate); } - log("\t,%s,%f,%s\n", (*countryItr)->getTag().c_str(), (*countryItr)->getLearningScore(), (*countryItr)->getTechGroup().c_str()); - - (*countryItr)->determineTechLevels(avgTechLevels, techData); } - for (vector::iterator countryItr = unlandedCountries.begin(); countryItr != unlandedCountries.end(); countryItr++) + else // (Configuration::getTechGroupMethod() == "culturalTech") { - map::iterator capitalItr = provinces.find( (*countryItr)->getCapital() ); - if (capitalItr != provinces.end()) + double catholicTech = 1.0 + ( ((double)(startDate.year - 1066) / (1453 - 1066)) * (3.5 - 1.0)); + double greekTech = (6.5/3) + ( ((double)(startDate.year - 1066) / (1453 - 1066)) * (3.5 - (6.5/3)) ); + double muslimTech = (6.2/3) + ( ((double)(startDate.year - 1066) / (1453 - 1066)) * (3.0 - (6.2/3)) ); + double otherTech = 0.0 + ( ((double)(startDate.year - 1066) / (1453 - 1066)) * (2.5 - 0.0) ); + log("\tCatholicTech: %f\n", catholicTech); + log("\tgreekTech: %f\n", greekTech); + log("\tmuslimTech: %f\n", muslimTech); + log("\totherTech: %f\n", otherTech); + + for (vector::iterator countryItr = convertedCountries.begin(); countryItr != convertedCountries.end(); countryItr++) { - (*countryItr)->setTechGroup( capitalItr->second->getOwner()->getTechGroup() ); + // get tech score + double techScore; + if ((*countryItr)->getProvinces().size() <= 0) + { + map::iterator capitalItr = provinces.find( (*countryItr)->getCapital() ); + if (capitalItr != provinces.end()) + { + capitalItr->second->getOwner()->determineTechScore(); + techScore = capitalItr->second->getOwner()->getTechScore(); + } + else + { + (*countryItr)->setTechGroup("western"); + log("\tWarning: %s had no capital, defaulting tech group to western\n", (*countryItr)->getTag().c_str()); + (*countryItr)->determineTechLevels(srcWorld.getAverageTechLevels(), techData); + log("\t,%s,%f,%s\n", (*countryItr)->getTag().c_str(), 0.0F, (*countryItr)->getTechGroup().c_str()); + continue; + } + } + else + { + (*countryItr)->determineTechScore(); + techScore = (*countryItr)->getTechScore(); + } + + // determine which decision category to use + string category; + if (CK2Religion::getReligion((*countryItr)->getReligion())->getGroup() == "muslim") + { + category = "muslim"; + } + else if (CK2Religion::getReligion((*countryItr)->getReligion())->getGroup() == "pagan_group") + { + category = "other"; + } + else if (CK2Religion::getReligion((*countryItr)->getReligion())->getGroup() == "zoroastrian_group") + { + category = "greek"; + } + else if (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "miaphysite") + { + category = "greek"; + } + else if (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "monophysite") + { + category = "greek"; + } + else if (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "monothelite") + { + category = "greek"; + } + else if ((*countryItr)->getPrimaryCulture() == "greek") + { + category = "greek"; + } + else if ((*countryItr)->getPrimaryCulture() == "georgian") + { + category = "greek"; + } + else if ((*countryItr)->getPrimaryCulture() == "armenian") + { + category = "greek"; + } + else if ( + (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "catholic") || + (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "cathar") || + (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "fraticelli") || + (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "waldensian") || + (CK2Religion::getReligion((*countryItr)->getReligion())->getName() == "lollard") + ) + { + if ((*countryItr)->getPrimaryCulture() == "german") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "english") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "saxon") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "dutch") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "frankish") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "norman") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "italian") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "occitan") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "basque") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "castillan") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "catalan") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "portuguese") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "irish") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "scottish") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "welsh") + { + category = "catholic"; + } + else if ((*countryItr)->getPrimaryCulture() == "breton") + { + category = "catholic"; + } + else + { + category = "other"; + } + } + else + { + category = "other"; + } + + //determine tech + string title = (*countryItr)->getSrcCountry()->getTitleString(); + if ( ( (title == "e_golden_horde") || (title == "e_il-khanate") || (title == "e_timurids") ) && (CK2Religion::getReligion((*countryItr)->getReligion())->getGroup() != "christian") ) + { + (*countryItr)->setTechGroup("nomad_group"); + } + else if (category == "catholic") + { + if (techScore >= catholicTech) + { + (*countryItr)->setTechGroup("western"); + } + else + { + (*countryItr)->setTechGroup("eastern"); + } + } + else if (category == "greek") + { + if (techScore >= catholicTech + 1.0) + { + (*countryItr)->setTechGroup("western"); + } + else if (techScore >= muslimTech) + { + (*countryItr)->setTechGroup("eastern"); + } + else + { + (*countryItr)->setTechGroup("ottoman"); + } + } + else if (category == "other") + { + if (techScore >= catholicTech + 0.5) + { + (*countryItr)->setTechGroup("western"); + } + else if (techScore >= otherTech) + { + (*countryItr)->setTechGroup("eastern"); + } + else + { + (*countryItr)->setTechGroup("ottoman"); + } + } + else // category == "muslim" + { + if (techScore >= catholicTech + 1.0) + { + (*countryItr)->setTechGroup("western"); + } + else if (techScore >= catholicTech + 0.5) + { + (*countryItr)->setTechGroup("eastern"); + } + else if (techScore >= greekTech) + { + (*countryItr)->setTechGroup("ottoman"); + } + else + { + (*countryItr)->setTechGroup("muslim"); + } + } + log("\t,%s,%f,%s\n", (*countryItr)->getTag().c_str(), techScore, (*countryItr)->getTechGroup().c_str()); } - else + + + // determine tech investment + for(map::iterator countryItr = countries.begin(); countryItr != countries.end(); countryItr++) { - (*countryItr)->setTechGroup("western"); - log("\tWarning: %s had no capital, defaulting tech group to western\n", (*countryItr)->getTag().c_str()); + countryItr->second->determineTechInvestment(techData, startDate); } - (*countryItr)->determineTechLevels(avgTechLevels, techData); - log("\t,%s,%f,%s\n", (*countryItr)->getTag().c_str(), 0.0F, (*countryItr)->getTechGroup().c_str()); - } - - for(map::iterator countryItr = countries.begin(); countryItr != countries.end(); countryItr++) - { - countryItr->second->determineTechInvestment(techData, startDate); } } -#pragma optimize("",on) + #define MAX_PRESTIGE 50.0 void EU3World::convertGovernments() diff --git a/TestConfigurations/Mod/configuration.txt b/TestConfigurations/Mod/configuration.txt index 5aa686a2d..269e3e836 100644 --- a/TestConfigurations/Mod/configuration.txt +++ b/TestConfigurations/Mod/configuration.txt @@ -7,6 +7,13 @@ configuration = CK2directory = "D:\Paradox Interactive\Crusader Kings II" + ### Tech Options + + # techGroupMethod: the method by which tech groups are determined. Options are: + # "learningRate" - use the CK2 learning rate to determine tech groups + # "culturalTech" - use the amount of tech gained in CK2, broken down by relious and culture groups, to determine tech. NOTE: do not use this option along with mods, as it relies heavily on default religions and cultures + techGroupMethod = "learningRate" + ### Economy (base tax, manpower, and population) Options diff --git a/TestConfigurations/Vanilla/configuration.txt b/TestConfigurations/Vanilla/configuration.txt index 5aa686a2d..269e3e836 100644 --- a/TestConfigurations/Vanilla/configuration.txt +++ b/TestConfigurations/Vanilla/configuration.txt @@ -7,6 +7,13 @@ configuration = CK2directory = "D:\Paradox Interactive\Crusader Kings II" + ### Tech Options + + # techGroupMethod: the method by which tech groups are determined. Options are: + # "learningRate" - use the CK2 learning rate to determine tech groups + # "culturalTech" - use the amount of tech gained in CK2, broken down by relious and culture groups, to determine tech. NOTE: do not use this option along with mods, as it relies heavily on default religions and cultures + techGroupMethod = "learningRate" + ### Economy (base tax, manpower, and population) Options