mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Nullkiller: improved citadel priority
This commit is contained in:
committed by
Andrii Danylchenko
parent
3822d788e8
commit
0d5ae20e64
@@ -10,6 +10,7 @@
|
|||||||
#include "../StdInc.h"
|
#include "../StdInc.h"
|
||||||
#include "../Engine/Nullkiller.h"
|
#include "../Engine/Nullkiller.h"
|
||||||
#include "../../../lib/mapping/CMap.h" //for victory conditions
|
#include "../../../lib/mapping/CMap.h" //for victory conditions
|
||||||
|
#include "../Engine/Nullkiller.h"
|
||||||
|
|
||||||
extern boost::thread_specific_ptr<CCallback> cb;
|
extern boost::thread_specific_ptr<CCallback> cb;
|
||||||
|
|
||||||
@@ -193,7 +194,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
|||||||
creature = creatureID.toCreature();
|
creature = creatureID.toCreature();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto info = BuildingInfo(buildPtr, creature, baseCreatureID);
|
auto info = BuildingInfo(buildPtr, creature, baseCreatureID, town, ai);
|
||||||
|
|
||||||
logAi->trace("checking %s", buildPtr->Name());
|
logAi->trace("checking %s", buildPtr->Name());
|
||||||
logAi->trace("buildInfo %s", info.toString());
|
logAi->trace("buildInfo %s", info.toString());
|
||||||
@@ -298,6 +299,7 @@ void TownDevelopmentInfo::addExistingDwelling(const BuildingInfo & existingDwell
|
|||||||
existingDwellings.push_back(existingDwelling);
|
existingDwellings.push_back(existingDwelling);
|
||||||
|
|
||||||
armyCost += existingDwelling.creatureCost * existingDwelling.creatureGrows;
|
armyCost += existingDwelling.creatureCost * existingDwelling.creatureGrows;
|
||||||
|
armyStrength += existingDwelling.armyStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TownDevelopmentInfo::addBuildingToBuild(const BuildingInfo & nextToBuild)
|
void TownDevelopmentInfo::addBuildingToBuild(const BuildingInfo & nextToBuild)
|
||||||
@@ -325,17 +327,22 @@ BuildingInfo::BuildingInfo()
|
|||||||
buildCostWithPrerequisits = 0;
|
buildCostWithPrerequisits = 0;
|
||||||
prerequisitesCount = 0;
|
prerequisitesCount = 0;
|
||||||
name = "";
|
name = "";
|
||||||
|
armyStrength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildingInfo::BuildingInfo(const CBuilding * building, const CCreature * creature, CreatureID baseCreature)
|
BuildingInfo::BuildingInfo(
|
||||||
|
const CBuilding * building,
|
||||||
|
const CCreature * creature,
|
||||||
|
CreatureID baseCreature,
|
||||||
|
const CGTownInstance * town,
|
||||||
|
Nullkiller * ai)
|
||||||
{
|
{
|
||||||
id = building->bid;
|
id = building->bid;
|
||||||
buildCost = building->resources;
|
buildCost = building->resources;
|
||||||
buildCostWithPrerequisits = building->resources;
|
buildCostWithPrerequisits = building->resources;
|
||||||
dailyIncome = building->produce;
|
dailyIncome = building->produce;
|
||||||
exists = false;;
|
exists = town->hasBuilt(id);
|
||||||
prerequisitesCount = 1;
|
prerequisitesCount = 1;
|
||||||
name = building->Name();
|
|
||||||
|
|
||||||
if(creature)
|
if(creature)
|
||||||
{
|
{
|
||||||
@@ -344,6 +351,23 @@ BuildingInfo::BuildingInfo(const CBuilding * building, const CCreature * creatur
|
|||||||
creatureCost = creature->cost;
|
creatureCost = creature->cost;
|
||||||
creatureLevel = creature->level;
|
creatureLevel = creature->level;
|
||||||
baseCreatureID = baseCreature;
|
baseCreatureID = baseCreature;
|
||||||
|
|
||||||
|
if(exists)
|
||||||
|
{
|
||||||
|
creatureGrows = town->creatureGrowth(creatureID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
creatureGrows = creature->growth;
|
||||||
|
|
||||||
|
if(town->hasBuilt(BuildingID::CASTLE))
|
||||||
|
creatureGrows *= 2;
|
||||||
|
else if(town->hasBuilt(BuildingID::CITADEL))
|
||||||
|
creatureGrows += creatureGrows / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
armyStrength = ai->armyManager->evaluateStackPower(creature, creatureGrows);
|
||||||
|
armyCost = creatureCost * creatureGrows;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -351,7 +375,9 @@ BuildingInfo::BuildingInfo(const CBuilding * building, const CCreature * creatur
|
|||||||
creatureID = CreatureID::NONE;
|
creatureID = CreatureID::NONE;
|
||||||
baseCreatureID = CreatureID::NONE;
|
baseCreatureID = CreatureID::NONE;
|
||||||
creatureCost = TResources();
|
creatureCost = TResources();
|
||||||
|
armyCost = TResources();
|
||||||
creatureLevel = 0;
|
creatureLevel = 0;
|
||||||
|
armyStrength = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "../AIUtility.h"
|
#include "../AIUtility.h"
|
||||||
#include "../../../lib/ResourceSet.h"
|
#include "../../../lib/ResourceSet.h"
|
||||||
|
|
||||||
|
class Nullkiller;
|
||||||
|
|
||||||
class DLL_EXPORT BuildingInfo
|
class DLL_EXPORT BuildingInfo
|
||||||
{
|
{
|
||||||
@@ -26,6 +27,8 @@ public:
|
|||||||
CreatureID baseCreatureID;
|
CreatureID baseCreatureID;
|
||||||
TResources dailyIncome;
|
TResources dailyIncome;
|
||||||
uint8_t prerequisitesCount;
|
uint8_t prerequisitesCount;
|
||||||
|
uint64_t armyStrength;
|
||||||
|
TResources armyCost;
|
||||||
std::string name;
|
std::string name;
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
bool canBuild = false;
|
bool canBuild = false;
|
||||||
@@ -33,7 +36,12 @@ public:
|
|||||||
|
|
||||||
BuildingInfo();
|
BuildingInfo();
|
||||||
|
|
||||||
BuildingInfo(const CBuilding* building, const CCreature* creature, CreatureID baseCreatureID);
|
BuildingInfo(
|
||||||
|
const CBuilding * building,
|
||||||
|
const CCreature * creature,
|
||||||
|
CreatureID baseCreature,
|
||||||
|
const CGTownInstance * town,
|
||||||
|
Nullkiller * ai);
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
};
|
};
|
||||||
@@ -47,13 +55,12 @@ public:
|
|||||||
TResources townDevelopmentCost;
|
TResources townDevelopmentCost;
|
||||||
TResources requiredResources;
|
TResources requiredResources;
|
||||||
TResources armyCost;
|
TResources armyCost;
|
||||||
int armyScore;
|
uint64_t armyStrength;
|
||||||
int economicsScore;
|
|
||||||
HeroRole townRole;
|
HeroRole townRole;
|
||||||
bool hasSomethingToBuild;
|
bool hasSomethingToBuild;
|
||||||
|
|
||||||
TownDevelopmentInfo(const CGTownInstance* town)
|
TownDevelopmentInfo(const CGTownInstance* town)
|
||||||
:town(town), armyScore(0), economicsScore(0), toBuild(), townDevelopmentCost(), requiredResources(), townRole(HeroRole::SCOUT), hasSomethingToBuild(false)
|
:town(town), armyStrength(0), toBuild(), townDevelopmentCost(), requiredResources(), townRole(HeroRole::SCOUT), hasSomethingToBuild(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +79,10 @@ private:
|
|||||||
TResources armyCost;
|
TResources armyCost;
|
||||||
TResources dailyIncome;
|
TResources dailyIncome;
|
||||||
float goldPreasure;
|
float goldPreasure;
|
||||||
|
Nullkiller * ai;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
BuildAnalyzer(Nullkiller * ai) : ai(ai) {}
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
TResources getResourcesRequiredNow() const;
|
TResources getResourcesRequiredNow() const;
|
||||||
|
|||||||
@@ -603,7 +603,7 @@ public:
|
|||||||
evaluationContext.goldReward += 7 * bi.dailyIncome[Res::GOLD] / 2; // 7 day income but half we already have
|
evaluationContext.goldReward += 7 * bi.dailyIncome[Res::GOLD] / 2; // 7 day income but half we already have
|
||||||
evaluationContext.heroRole = HeroRole::MAIN;
|
evaluationContext.heroRole = HeroRole::MAIN;
|
||||||
evaluationContext.movementCostByRole[evaluationContext.heroRole] += bi.prerequisitesCount;
|
evaluationContext.movementCostByRole[evaluationContext.heroRole] += bi.prerequisitesCount;
|
||||||
evaluationContext.strategicalValue += buildThis.townInfo.armyScore / 50000.0;
|
evaluationContext.strategicalValue += buildThis.townInfo.armyStrength / 50000.0;
|
||||||
evaluationContext.goldCost += bi.buildCostWithPrerequisits[Res::GOLD];
|
evaluationContext.goldCost += bi.buildCostWithPrerequisits[Res::GOLD];
|
||||||
|
|
||||||
if(bi.creatureID != CreatureID::NONE)
|
if(bi.creatureID != CreatureID::NONE)
|
||||||
@@ -611,7 +611,7 @@ public:
|
|||||||
if(bi.baseCreatureID == bi.creatureID)
|
if(bi.baseCreatureID == bi.creatureID)
|
||||||
{
|
{
|
||||||
evaluationContext.strategicalValue += 0.5f + 0.1f * bi.creatureLevel / (float)bi.prerequisitesCount;
|
evaluationContext.strategicalValue += 0.5f + 0.1f * bi.creatureLevel / (float)bi.prerequisitesCount;
|
||||||
evaluationContext.armyReward += evaluationContext.evaluator.ai->armyManager->evaluateStackPower(bi.creatureID.toCreature(), bi.creatureGrows);
|
evaluationContext.armyReward += bi.armyStrength;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -619,6 +619,11 @@ public:
|
|||||||
evaluationContext.armyReward += evaluationContext.evaluator.getUpgradeArmyReward(buildThis.town, bi);
|
evaluationContext.armyReward += evaluationContext.evaluator.getUpgradeArmyReward(buildThis.town, bi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(bi.id == BuildingID::CITADEL || bi.id == BuildingID::CASTLE)
|
||||||
|
{
|
||||||
|
evaluationContext.strategicalValue += buildThis.town->creatures.size() * 0.2f;
|
||||||
|
evaluationContext.armyReward += buildThis.townInfo.armyStrength / 2;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
evaluationContext.strategicalValue += evaluationContext.evaluator.ai->buildAnalyzer->getGoldPreasure() * evaluationContext.goldReward / 2200.0f;
|
evaluationContext.strategicalValue += evaluationContext.evaluator.ai->buildAnalyzer->getGoldPreasure() * evaluationContext.goldReward / 2200.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user