diff --git a/AI/VCAI/BuildingManager.cpp b/AI/VCAI/BuildingManager.cpp index f5529777f..d63f78e07 100644 --- a/AI/VCAI/BuildingManager.cpp +++ b/AI/VCAI/BuildingManager.cpp @@ -139,13 +139,14 @@ void BuildingManager::setAI(VCAI * AI) //Set of buildings for different goals. Does not include any prerequisites. static const std::vector essential = { BuildingID::TAVERN, BuildingID::TOWN_HALL }; static const std::vector basicGoldSource = { BuildingID::TOWN_HALL, BuildingID::CITY_HALL }; +static const std::vector cityhallRequirements = { BuildingID::TOWN_HALL, BuildingID::MARKETPLACE, BuildingID::BLACKSMITH, BuildingID::MAGES_GUILD_1 }; +static const std::vector defence = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE }; static const std::vector capitolAndRequirements = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::CAPITOL }; static const std::vector unitsSource = { BuildingID::DWELL_LVL_1, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3, BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7 }; static const std::vector unitsUpgrade = { BuildingID::DWELL_LVL_1_UP, BuildingID::DWELL_LVL_2_UP, BuildingID::DWELL_LVL_3_UP, BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP }; -static const std::vector unitGrowth = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::HORDE_1, -BuildingID::HORDE_1_UPGR, BuildingID::HORDE_2, BuildingID::HORDE_2_UPGR }; +static const std::vector unitGrowth = { BuildingID::HORDE_1, BuildingID::HORDE_1_UPGR, BuildingID::HORDE_2, BuildingID::HORDE_2_UPGR }; static const std::vector _spells = { BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3, BuildingID::MAGES_GUILD_4, BuildingID::MAGES_GUILD_5 }; static const std::vector extra = { BuildingID::RESOURCE_SILO, BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3, @@ -172,10 +173,38 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) if(tryBuildAnyStructure(t, essential)) return true; - //the more gold the better and less problems later //TODO: what about building mage guild / marketplace etc. with city hall disabled in editor? - if(tryBuildNextStructure(t, basicGoldSource)) + if (cb->getDate(Date::DAY_OF_WEEK) < 5) // first 4 days of week - try to focus on dwellings + { + if (tryBuildNextStructure(t, unitsSource, 4)) + return true; + } + + if (cb->getDate(Date::DAY_OF_WEEK) > 4) // last 3 days of week - try to focus on growth by building Fort/Citadel/Castle + { + if (tryBuildNextStructure(t, defence, 3)) + return true; + } + + if (t->hasBuilt(BuildingID::CASTLE)) + { + if (tryBuildAnyStructure(t, unitGrowth, 4)) + return true; + } + + //make required structures for City Hall + if(tryBuildNextStructure(t, cityhallRequirements)) return true; + //try to make City Hall + for (int i = 0; i < cityhallRequirements.size(); i++) + { + if (t->hasBuilt(cityhallRequirements[i])) + { + if (tryBuildThisStructure(t, BuildingID::CITY_HALL)) + return true; + } + } + //workaround for mantis #2696 - build capitol with separate algorithm if it is available if(vstd::contains(t->builtBuildings, BuildingID::CITY_HALL) && getMaxPossibleGoldBuilding(t) == BuildingID::CAPITOL) { @@ -183,25 +212,6 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) return true; } - if(!t->hasBuilt(BuildingID::FORT)) //in vast majority of situations fort is top priority building if we already have city hall, TODO: unite with unitGrowth building chain - if(tryBuildThisStructure(t, BuildingID::FORT)) - return true; - - - - if (cb->getDate(Date::DAY_OF_WEEK) > 6) // last 2 days of week - try to focus on growth - { - if (tryBuildNextStructure(t, unitGrowth, 2)) - return true; - } - - //try building dwellings - if (t->hasBuilt(BuildingID::FORT)) - { - if (tryBuildAnyStructure(t, unitsSource, 8 - cb->getDate(Date::DAY_OF_WEEK))) - return true; - } - //try to upgrade dwelling for (int i = 0; i < unitsUpgrade.size(); i++) {