mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Fix typos using https://github.com/crate-ci/typos
Changes were reviewed manually
This commit is contained in:
@@ -176,7 +176,7 @@ void CBattleAI::activeStack(const BattleID & battleID, const CStack * stack )
|
||||
movesSkippedByDefense = 0;
|
||||
}
|
||||
|
||||
logAi->trace("BattleAI decission made in %lld", timeElapsed(start));
|
||||
logAi->trace("BattleAI decision made in %lld", timeElapsed(start));
|
||||
|
||||
cb->battleMakeUnitAction(battleID, result);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ struct CurrentOffensivePotential
|
||||
return ourPotential - enemyPotential;
|
||||
}
|
||||
};
|
||||
*/ // These lines may be usefull but they are't used in the code.
|
||||
*/ // These lines may be useful but they are't used in the code.
|
||||
|
||||
class CBattleAI : public CBattleGameInterface
|
||||
{
|
||||
|
||||
@@ -196,7 +196,7 @@ BattleAction BattleEvaluator::selectStackAction(const CStack * stack)
|
||||
}
|
||||
}
|
||||
|
||||
//ThreatMap threatsToUs(stack); // These lines may be usefull but they are't used in the code.
|
||||
//ThreatMap threatsToUs(stack); // These lines may be useful but they are't used in the code.
|
||||
if(moveTarget.scorePerTurn > score)
|
||||
{
|
||||
score = moveTarget.score;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
AttackerValue::AttackerValue()
|
||||
: value(0),
|
||||
isRetalitated(false)
|
||||
isRetaliated(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -57,14 +57,14 @@ float BattleExchangeVariant::trackAttack(
|
||||
|
||||
attackValue -= attackerDamageReduce;
|
||||
dpsScore.ourDamageReduce += attackerDamageReduce;
|
||||
attackerValue[unitToUpdate->unitId()].isRetalitated = true;
|
||||
attackerValue[unitToUpdate->unitId()].isRetaliated = true;
|
||||
|
||||
unitToUpdate->damage(retaliationDamage);
|
||||
defender->afterAttack(false, true);
|
||||
|
||||
#if BATTLE_TRACE_LEVEL>=1
|
||||
logAi->trace(
|
||||
"%s -> %s, ap retalitation, %s, dps: %2f, score: %2f",
|
||||
"%s -> %s, ap retaliation, %s, dps: %2f, score: %2f",
|
||||
defender->getDescription(),
|
||||
unitToUpdate->getDescription(),
|
||||
ap.attack.shooting ? "shot" : "mellee",
|
||||
@@ -185,7 +185,7 @@ float BattleExchangeVariant::trackAttack(
|
||||
if(isOurAttack)
|
||||
{
|
||||
dpsScore.ourDamageReduce += attackerDamageReduce;
|
||||
attackerValue[attacker->unitId()].isRetalitated = true;
|
||||
attackerValue[attacker->unitId()].isRetaliated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ struct BattleScore
|
||||
struct AttackerValue
|
||||
{
|
||||
float value;
|
||||
bool isRetalitated;
|
||||
bool isRetaliated;
|
||||
BattleHex position;
|
||||
|
||||
AttackerValue();
|
||||
|
||||
@@ -70,4 +70,4 @@ ThreatMap::ThreatMap(const CStack *Endangered) : endangered(Endangered)
|
||||
});
|
||||
}
|
||||
}
|
||||
*/ // These lines may be usefull but they are't used in the code.
|
||||
*/ // These lines may be useful but they are't used in the code.
|
||||
|
||||
@@ -22,4 +22,4 @@ public:
|
||||
std::array<int, GameConstants::BFIELD_SIZE> sufferedDamage;
|
||||
|
||||
ThreatMap(const CStack *Endangered);
|
||||
};*/ // These lines may be usefull but they are't used in the code.
|
||||
};*/ // These lines may be useful but they are't used in the code.
|
||||
|
||||
@@ -500,7 +500,7 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
|
||||
if(relations == PlayerRelations::ENEMIES)
|
||||
{
|
||||
//we want to visit objects owned by oppponents
|
||||
//addVisitableObj(obj); // TODO: Remove once save compatability broken. In past owned objects were removed from this set
|
||||
//addVisitableObj(obj); // TODO: Remove once save compatibility broken. In past owned objects were removed from this set
|
||||
nullkiller->memory->markObjectUnvisited(obj);
|
||||
}
|
||||
else if(relations == PlayerRelations::SAME_PLAYER && obj->ID == Obj::TOWN)
|
||||
@@ -705,7 +705,7 @@ void AIGateway::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelI
|
||||
NET_EVENT_HANDLER;
|
||||
status.addQuery(askID, boost::str(boost::format("Teleport dialog query with %d exits") % exits.size()));
|
||||
|
||||
int choosenExit = -1;
|
||||
int chosenExit = -1;
|
||||
if(impassable)
|
||||
{
|
||||
nullkiller->memory->knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
|
||||
@@ -714,14 +714,14 @@ void AIGateway::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelI
|
||||
{
|
||||
auto neededExit = std::make_pair(destinationTeleport, destinationTeleportPos);
|
||||
if(destinationTeleport != ObjectInstanceID() && vstd::contains(exits, neededExit))
|
||||
choosenExit = vstd::find_pos(exits, neededExit);
|
||||
chosenExit = vstd::find_pos(exits, neededExit);
|
||||
}
|
||||
|
||||
for(auto exit : exits)
|
||||
{
|
||||
if(status.channelProbing() && exit.first == destinationTeleport)
|
||||
{
|
||||
choosenExit = vstd::find_pos(exits, exit);
|
||||
chosenExit = vstd::find_pos(exits, exit);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@@ -739,7 +739,7 @@ void AIGateway::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelI
|
||||
|
||||
requestActionASAP([=]()
|
||||
{
|
||||
answerQuery(askID, choosenExit);
|
||||
answerQuery(askID, chosenExit);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1452,7 +1452,7 @@ void AIGateway::tryRealize(Goals::Trade & g) //trade
|
||||
if(cb->getResourceAmount(GameResID(g.resID)) >= g.value) //goal is already fulfilled. Why we need this check, anyway?
|
||||
throw goalFulfilledException(sptr(g));
|
||||
|
||||
int accquiredResources = 0;
|
||||
int acquiredResources = 0;
|
||||
if(const CGObjectInstance * obj = cb->getObj(ObjectInstanceID(g.objid), false))
|
||||
{
|
||||
if(const auto * m = dynamic_cast<const IMarket*>(obj))
|
||||
@@ -1472,8 +1472,8 @@ void AIGateway::tryRealize(Goals::Trade & g) //trade
|
||||
if (toGive) //don't try to sell 0 resources
|
||||
{
|
||||
cb->trade(m, EMarketMode::RESOURCE_RESOURCE, res, GameResID(g.resID), toGive);
|
||||
accquiredResources = static_cast<int>(toGet * (it->resVal / toGive));
|
||||
logAi->debug("Traded %d of %s for %d of %s at %s", toGive, res, accquiredResources, g.resID, obj->getObjectName());
|
||||
acquiredResources = static_cast<int>(toGet * (it->resVal / toGive));
|
||||
logAi->debug("Traded %d of %s for %d of %s at %s", toGive, res, acquiredResources, g.resID, obj->getObjectName());
|
||||
}
|
||||
if (cb->getResourceAmount(GameResID(g.resID)))
|
||||
throw goalFulfilledException(sptr(g)); //we traded all we needed
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
AIGateway();
|
||||
virtual ~AIGateway();
|
||||
|
||||
//TODO: extract to apropriate goals
|
||||
//TODO: extract to appropriate goals
|
||||
void tryRealize(Goals::DigAtTile & g);
|
||||
void tryRealize(Goals::Trade & g);
|
||||
|
||||
|
||||
@@ -434,9 +434,9 @@ bool townHasFreeTavern(const CGTownInstance * town)
|
||||
if(!town->hasBuilt(BuildingID::TAVERN)) return false;
|
||||
if(!town->visitingHero) return true;
|
||||
|
||||
bool canMoveVisitingHeroToGarnison = !town->getUpperArmy()->stacksCount();
|
||||
bool canMoveVisitingHeroToGarrison = !town->getUpperArmy()->stacksCount();
|
||||
|
||||
return canMoveVisitingHeroToGarnison;
|
||||
return canMoveVisitingHeroToGarrison;
|
||||
}
|
||||
|
||||
uint64_t getHeroArmyStrengthWithCommander(const CGHeroInstance * hero, const CCreatureSet * heroArmy)
|
||||
|
||||
@@ -267,7 +267,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
|
||||
BuildingInfo prerequisite = getBuildingOrPrerequisite(town, missingBuildings[0], excludeDwellingDependencies);
|
||||
|
||||
prerequisite.buildCostWithPrerequisits += info.buildCost;
|
||||
prerequisite.buildCostWithPrerequisites += info.buildCost;
|
||||
prerequisite.creatureCost = info.creatureCost;
|
||||
prerequisite.creatureGrows = info.creatureGrows;
|
||||
prerequisite.creatureLevel = info.creatureLevel;
|
||||
@@ -340,7 +340,7 @@ void TownDevelopmentInfo::addExistingDwelling(const BuildingInfo & existingDwell
|
||||
|
||||
void TownDevelopmentInfo::addBuildingToBuild(const BuildingInfo & nextToBuild)
|
||||
{
|
||||
townDevelopmentCost += nextToBuild.buildCostWithPrerequisits;
|
||||
townDevelopmentCost += nextToBuild.buildCostWithPrerequisites;
|
||||
|
||||
if(nextToBuild.canBuild)
|
||||
{
|
||||
@@ -361,7 +361,7 @@ BuildingInfo::BuildingInfo()
|
||||
creatureGrows = 0;
|
||||
creatureID = CreatureID::NONE;
|
||||
buildCost = 0;
|
||||
buildCostWithPrerequisits = 0;
|
||||
buildCostWithPrerequisites = 0;
|
||||
prerequisitesCount = 0;
|
||||
name.clear();
|
||||
armyStrength = 0;
|
||||
@@ -376,7 +376,7 @@ BuildingInfo::BuildingInfo(
|
||||
{
|
||||
id = building->bid;
|
||||
buildCost = building->resources;
|
||||
buildCostWithPrerequisits = building->resources;
|
||||
buildCostWithPrerequisites = building->resources;
|
||||
dailyIncome = building->produce;
|
||||
exists = town->hasBuilt(id);
|
||||
prerequisitesCount = 1;
|
||||
|
||||
@@ -22,7 +22,7 @@ class DLL_EXPORT BuildingInfo
|
||||
public:
|
||||
BuildingID id;
|
||||
TResources buildCost;
|
||||
TResources buildCostWithPrerequisits;
|
||||
TResources buildCostWithPrerequisites;
|
||||
int creatureGrows;
|
||||
uint8_t creatureLevel;
|
||||
TResources creatureCost;
|
||||
|
||||
@@ -240,7 +240,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
if(path.turn() <= threat.turn - 2)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Defer defence of %s by %s because he has enough time to reach the town next trun",
|
||||
logAi->trace("Defer defence of %s by %s because he has enough time to reach the town next turn",
|
||||
town->getObjectName(),
|
||||
path.targetHero->getObjectName());
|
||||
#endif
|
||||
|
||||
@@ -399,7 +399,7 @@ void Nullkiller::makeTurn()
|
||||
|
||||
auto selectedTasks = buildPlan(bestTasks);
|
||||
|
||||
logAi->debug("Decission madel in %ld", timeElapsed(start));
|
||||
logAi->debug("Decision madel in %ld", timeElapsed(start));
|
||||
|
||||
if(selectedTasks.empty())
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
#define MIN_AI_STRENGHT (0.5f) //lower when combat AI gets smarter
|
||||
#define MIN_AI_STRENGTH (0.5f) //lower when combat AI gets smarter
|
||||
#define UNGUARDED_OBJECT (100.0f) //we consider unguarded objects 100 times weaker than us
|
||||
const float MIN_CRITICAL_VALUE = 2.0f;
|
||||
|
||||
@@ -1000,7 +1000,7 @@ public:
|
||||
evaluationContext.goldReward += 7 * bi.dailyIncome[EGameResID::GOLD] / 2; // 7 day income but half we already have
|
||||
evaluationContext.heroRole = HeroRole::MAIN;
|
||||
evaluationContext.movementCostByRole[evaluationContext.heroRole] += bi.prerequisitesCount;
|
||||
evaluationContext.goldCost += bi.buildCostWithPrerequisits[EGameResID::GOLD];
|
||||
evaluationContext.goldCost += bi.buildCostWithPrerequisites[EGameResID::GOLD];
|
||||
evaluationContext.closestWayRatio = 1;
|
||||
|
||||
if(bi.creatureID != CreatureID::NONE)
|
||||
|
||||
@@ -34,13 +34,13 @@ void BuyArmy::accept(AIGateway * ai)
|
||||
ui64 valueBought = 0;
|
||||
//buy the stacks with largest AI value
|
||||
|
||||
auto upgradeSuccessfull = ai->makePossibleUpgrades(town);
|
||||
auto upgradeSuccessful = ai->makePossibleUpgrades(town);
|
||||
|
||||
auto armyToBuy = ai->nullkiller->armyManager->getArmyAvailableToBuy(town->getUpperArmy(), town);
|
||||
|
||||
if(armyToBuy.empty())
|
||||
{
|
||||
if(upgradeSuccessfull)
|
||||
if(upgradeSuccessful)
|
||||
return;
|
||||
|
||||
throw cannotFulfillGoalException("No creatures to buy.");
|
||||
|
||||
@@ -234,7 +234,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
|
||||
if(node->turns == 0)
|
||||
{
|
||||
logAi->error(
|
||||
"Unable to complete chain. Expected hero %s to arive to %s but he is at %s",
|
||||
"Unable to complete chain. Expected hero %s to arrive to %s but he is at %s",
|
||||
hero->getNameTranslated(),
|
||||
node->coord.toString(),
|
||||
hero->visitablePos().toString());
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace NKAI
|
||||
std::shared_ptr<boost::multi_array<AIPathNode, 4>> AISharedStorage::shared;
|
||||
uint64_t AISharedStorage::version = 0;
|
||||
boost::mutex AISharedStorage::locker;
|
||||
std::set<int3> commitedTiles;
|
||||
std::set<int3> commitedTilesInitial;
|
||||
std::set<int3> committedTiles;
|
||||
std::set<int3> committedTilesInitial;
|
||||
|
||||
|
||||
const uint64_t FirstActorMask = 1;
|
||||
@@ -36,7 +36,7 @@ const uint64_t MIN_ARMY_STRENGTH_FOR_CHAIN = 5000;
|
||||
const uint64_t MIN_ARMY_STRENGTH_FOR_NEXT_ACTOR = 1000;
|
||||
const uint64_t CHAIN_MAX_DEPTH = 4;
|
||||
|
||||
const bool DO_NOT_SAVE_TO_COMMITED_TILES = false;
|
||||
const bool DO_NOT_SAVE_TO_COMMITTED_TILES = false;
|
||||
|
||||
AISharedStorage::AISharedStorage(int3 sizes)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ void AIPathNode::addSpecialAction(std::shared_ptr<const SpecialAction> action)
|
||||
AINodeStorage::AINodeStorage(const Nullkiller * ai, const int3 & Sizes)
|
||||
: sizes(Sizes), ai(ai), cb(ai->cb.get()), nodes(Sizes)
|
||||
{
|
||||
accesibility = std::make_unique<boost::multi_array<EPathAccessibility, 4>>(
|
||||
accessibility = std::make_unique<boost::multi_array<EPathAccessibility, 4>>(
|
||||
boost::extents[sizes.z][sizes.x][sizes.y][EPathfindingLayer::NUM_LAYERS]);
|
||||
|
||||
dangerEvaluator.reset(new FuzzyHelper(ai));
|
||||
@@ -157,7 +157,7 @@ void AINodeStorage::initialize(const PathfinderOptions & options, const CGameSta
|
||||
void AINodeStorage::clear()
|
||||
{
|
||||
actors.clear();
|
||||
commitedTiles.clear();
|
||||
committedTiles.clear();
|
||||
heroChainPass = EHeroChainPass::INITIAL;
|
||||
heroChainTurn = 0;
|
||||
heroChainMaxTurns = 1;
|
||||
@@ -276,7 +276,7 @@ void AINodeStorage::commit(
|
||||
int turn,
|
||||
int movementLeft,
|
||||
float cost,
|
||||
bool saveToCommited) const
|
||||
bool saveToCommitted) const
|
||||
{
|
||||
destination->action = action;
|
||||
destination->setCost(cost);
|
||||
@@ -290,7 +290,7 @@ void AINodeStorage::commit(
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Commited %s -> %s, layer: %d, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld",
|
||||
"Committed %s -> %s, layer: %d, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld",
|
||||
source->coord.toString(),
|
||||
destination->coord.toString(),
|
||||
destination->layer,
|
||||
@@ -302,9 +302,9 @@ void AINodeStorage::commit(
|
||||
destination->actor->armyValue);
|
||||
#endif
|
||||
|
||||
if(saveToCommited && destination->turns <= heroChainTurn)
|
||||
if(saveToCommitted && destination->turns <= heroChainTurn)
|
||||
{
|
||||
commitedTiles.insert(destination->coord);
|
||||
committedTiles.insert(destination->coord);
|
||||
}
|
||||
|
||||
if(destination->turns == source->turns)
|
||||
@@ -376,7 +376,7 @@ bool AINodeStorage::increaseHeroChainTurnLimit()
|
||||
return false;
|
||||
|
||||
heroChainTurn++;
|
||||
commitedTiles.clear();
|
||||
committedTiles.clear();
|
||||
|
||||
for(auto layer : phisycalLayers)
|
||||
{
|
||||
@@ -386,7 +386,7 @@ bool AINodeStorage::increaseHeroChainTurnLimit()
|
||||
{
|
||||
if(node.turns <= heroChainTurn && node.action != EPathNodeAction::UNKNOWN)
|
||||
{
|
||||
commitedTiles.insert(pos);
|
||||
committedTiles.insert(pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ bool AINodeStorage::calculateHeroChain()
|
||||
heroChainPass = EHeroChainPass::CHAIN;
|
||||
heroChain.clear();
|
||||
|
||||
std::vector<int3> data(commitedTiles.begin(), commitedTiles.end());
|
||||
std::vector<int3> data(committedTiles.begin(), committedTiles.end());
|
||||
|
||||
if(data.size() > 100)
|
||||
{
|
||||
@@ -578,7 +578,7 @@ bool AINodeStorage::calculateHeroChain()
|
||||
task.flushResult(heroChain);
|
||||
}
|
||||
|
||||
commitedTiles.clear();
|
||||
committedTiles.clear();
|
||||
|
||||
return !heroChain.empty();
|
||||
}
|
||||
@@ -594,7 +594,7 @@ bool AINodeStorage::selectFirstActor()
|
||||
});
|
||||
|
||||
chainMask = strongest->chainMask;
|
||||
commitedTilesInitial = commitedTiles;
|
||||
committedTilesInitial = committedTiles;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -629,7 +629,7 @@ bool AINodeStorage::selectNextActor()
|
||||
return false;
|
||||
|
||||
chainMask = nextActor->get()->chainMask;
|
||||
commitedTiles = commitedTilesInitial;
|
||||
committedTiles = committedTilesInitial;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -656,7 +656,7 @@ void HeroChainCalculationTask::cleanupInefectiveChains(std::vector<ExchangeCandi
|
||||
if(isNotEffective)
|
||||
{
|
||||
logAi->trace(
|
||||
"Skip exchange %s[%x] -> %s[%x] at %s is ineficient",
|
||||
"Skip exchange %s[%x] -> %s[%x] at %s is inefficient",
|
||||
chainInfo.otherParent->actor->toString(),
|
||||
chainInfo.otherParent->actor->chainMask,
|
||||
chainInfo.carrierParent->actor->toString(),
|
||||
@@ -756,7 +756,7 @@ void HeroChainCalculationTask::calculateHeroChain(
|
||||
if(hasLessMp && hasLessExperience)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace("Exchange at %s is ineficient. Blocked.", carrier->coord.toString());
|
||||
logAi->trace("Exchange at %s is inefficient. Blocked.", carrier->coord.toString());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -825,7 +825,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
|
||||
chainInfo.turns,
|
||||
chainInfo.moveRemains,
|
||||
chainInfo.getCost(),
|
||||
DO_NOT_SAVE_TO_COMMITED_TILES);
|
||||
DO_NOT_SAVE_TO_COMMITTED_TILES);
|
||||
|
||||
if(carrier->specialAction || carrier->chainOther)
|
||||
{
|
||||
@@ -1119,7 +1119,7 @@ struct TownPortalFinder
|
||||
bestNode->turns,
|
||||
bestNode->moveRemains - movementNeeded,
|
||||
movementCost,
|
||||
DO_NOT_SAVE_TO_COMMITED_TILES);
|
||||
DO_NOT_SAVE_TO_COMMITTED_TILES);
|
||||
|
||||
node->theNodeBefore = bestNode;
|
||||
node->addSpecialAction(std::make_shared<AIPathfinding::TownPortalAction>(targetTown));
|
||||
@@ -1281,7 +1281,7 @@ bool AINodeStorage::isOtherChainBetter(
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Block ineficient battle move %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
"Block inefficient battle move %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
source->coord.toString(),
|
||||
candidateNode.coord.toString(),
|
||||
candidateNode.actor->hero->getNameTranslated(),
|
||||
@@ -1305,7 +1305,7 @@ bool AINodeStorage::isOtherChainBetter(
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Block ineficient move because of stronger army %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
"Block inefficient move because of stronger army %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
source->coord.toString(),
|
||||
candidateNode.coord.toString(),
|
||||
candidateNode.actor->hero->getNameTranslated(),
|
||||
@@ -1331,7 +1331,7 @@ bool AINodeStorage::isOtherChainBetter(
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Block ineficient move because of stronger hero %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
"Block inefficient move because of stronger hero %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
source->coord.toString(),
|
||||
candidateNode.coord.toString(),
|
||||
candidateNode.actor->hero->getNameTranslated(),
|
||||
|
||||
@@ -165,7 +165,7 @@ class AINodeStorage : public INodeStorage
|
||||
private:
|
||||
int3 sizes;
|
||||
|
||||
std::unique_ptr<boost::multi_array<EPathAccessibility, 4>> accesibility;
|
||||
std::unique_ptr<boost::multi_array<EPathAccessibility, 4>> accessibility;
|
||||
|
||||
const CPlayerSpecificInfoCallback * cb;
|
||||
const Nullkiller * ai;
|
||||
@@ -214,7 +214,7 @@ public:
|
||||
int turn,
|
||||
int movementLeft,
|
||||
float cost,
|
||||
bool saveToCommited = true) const;
|
||||
bool saveToCommitted = true) const;
|
||||
|
||||
inline const AIPathNode * getAINode(const CGPathNode * node) const
|
||||
{
|
||||
@@ -257,7 +257,7 @@ public:
|
||||
const AIPathNode & candidateNode,
|
||||
const AIPathNode & other) const;
|
||||
|
||||
bool isMovementIneficient(const PathNodeInfo & source, CDestinationNodeInfo & destination) const
|
||||
bool isMovementInefficient(const PathNodeInfo & source, CDestinationNodeInfo & destination) const
|
||||
{
|
||||
return hasBetterChain(source, destination);
|
||||
}
|
||||
@@ -287,12 +287,12 @@ public:
|
||||
|
||||
inline EPathAccessibility getAccessibility(const int3 & tile, EPathfindingLayer layer) const
|
||||
{
|
||||
return (*this->accesibility)[tile.z][tile.x][tile.y][layer];
|
||||
return (*this->accessibility)[tile.z][tile.x][tile.y][layer];
|
||||
}
|
||||
|
||||
inline void resetTile(const int3 & tile, EPathfindingLayer layer, EPathAccessibility tileAccessibility)
|
||||
{
|
||||
(*this->accesibility)[tile.z][tile.x][tile.y][layer] = tileAccessibility;
|
||||
(*this->accessibility)[tile.z][tile.x][tile.y][layer] = tileAccessibility;
|
||||
}
|
||||
|
||||
inline int getBucket(const ChainActor * actor) const
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace AIPathfinding
|
||||
if(hero->canCastThisSpell(summonBoatSpell)
|
||||
&& hero->getSpellSchoolLevel(summonBoatSpell) >= MasteryLevel::ADVANCED)
|
||||
{
|
||||
// TODO: For lower school level we might need to check the existance of some boat
|
||||
// TODO: For lower school level we might need to check the existence of some boat
|
||||
summonableVirtualBoats[hero] = std::make_shared<SummonBoatAction>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace AIPathfinding
|
||||
const PathfinderConfig * pathfinderConfig,
|
||||
CPathfinderHelper * pathfinderHelper) const
|
||||
{
|
||||
if(nodeStorage->isMovementIneficient(source, destination))
|
||||
if(nodeStorage->isMovementInefficient(source, destination))
|
||||
{
|
||||
destination.node->locked = true;
|
||||
destination.blocked = true;
|
||||
|
||||
@@ -41,7 +41,7 @@ TSubgoal BuildThis::whatToDoToAchieve()
|
||||
{
|
||||
case EBuildingState::ALLOWED:
|
||||
town = candidateTown;
|
||||
break; //TODO: look for prerequisites? this is not our reponsibility
|
||||
break; //TODO: look for prerequisites? this is not our responsibility
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ TGoalVec ClearWayTo::getAllPossibleSubgoals()
|
||||
if(ret.empty())
|
||||
{
|
||||
logAi->warn("There is no known way to clear the way to tile %s", tile.toString());
|
||||
throw goalFulfilledException(sptr(ClearWayTo(tile))); //make sure asigned hero gets unlocked
|
||||
throw goalFulfilledException(sptr(ClearWayTo(tile))); //make sure assigned hero gets unlocked
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -53,7 +53,7 @@ TSubgoal VisitHero::whatToDoToAchieve()
|
||||
|
||||
bool VisitHero::fulfillsMe(TSubgoal goal)
|
||||
{
|
||||
//TODO: VisitObj shoudl not be used for heroes, but...
|
||||
//TODO: VisitObj should not be used for heroes, but...
|
||||
if(goal->goalType == VISIT_TILE)
|
||||
{
|
||||
auto obj = cb->getObj(ObjectInstanceID(objid));
|
||||
|
||||
@@ -74,7 +74,7 @@ TSubgoal Win::whatToDoToAchieve()
|
||||
case EventCondition::HAVE_BUILDING:
|
||||
{
|
||||
// TODO build other buildings apart from Grail
|
||||
// goal.objectType = buidingID to build
|
||||
// goal.objectType = buildingID to build
|
||||
// goal.object = optional, town in which building should be built
|
||||
// Represents "Improve town" condition from H3 (but unlike H3 it consists from 2 separate conditions)
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ bool AINodeStorage::hasBetterChain(const PathNodeInfo & source, CDestinationNode
|
||||
{
|
||||
#ifdef VCMI_TRACE_PATHFINDER
|
||||
logAi->trace(
|
||||
"Block ineficient move %s:->%s, mask=%i, mp diff: %i",
|
||||
"Block inefficient move %s:->%s, mask=%i, mp diff: %i",
|
||||
source.coord.toString(),
|
||||
destination.coord.toString(),
|
||||
destinationNode->chainMask,
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace AIPathfinding
|
||||
if(hero->canCastThisSpell(summonBoatSpell)
|
||||
&& hero->getSpellSchoolLevel(summonBoatSpell) >= MasteryLevel::ADVANCED)
|
||||
{
|
||||
// TODO: For lower school level we might need to check the existance of some boat
|
||||
// TODO: For lower school level we might need to check the existence of some boat
|
||||
summonableVirtualBoat.reset(new SummonBoatAction());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ TResources ResourceManager::estimateIncome() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ResourceManager::reserveResoures(const TResources & res, Goals::TSubgoal goal)
|
||||
void ResourceManager::reserveResources(const TResources & res, Goals::TSubgoal goal)
|
||||
{
|
||||
if (!goal->invalid())
|
||||
tryPush(ResourceObjective(res, goal));
|
||||
@@ -315,7 +315,7 @@ bool ResourceManager::removeOutdatedObjectives(std::function<bool(const Goals::T
|
||||
TResources ResourceManager::reservedResources() const
|
||||
{
|
||||
TResources res;
|
||||
for (auto it : queue) //substract the value of reserved goals
|
||||
for (auto it : queue) //subtract the value of reserved goals
|
||||
res += it.resources;
|
||||
return res;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ TResources ResourceManager::reservedResources() const
|
||||
TResources ResourceManager::freeResources() const
|
||||
{
|
||||
TResources myRes = cb->getResourceAmount();
|
||||
myRes -= reservedResources(); //substract the value of reserved goals
|
||||
myRes -= reservedResources(); //subtract the value of reserved goals
|
||||
|
||||
for (auto & val : myRes)
|
||||
vstd::amax(val, 0); //never negative
|
||||
|
||||
@@ -24,7 +24,7 @@ struct DLL_EXPORT ResourceObjective
|
||||
ResourceObjective(const TResources &res, Goals::TSubgoal goal);
|
||||
bool operator < (const ResourceObjective &ro) const;
|
||||
|
||||
TResources resources; //how many resoures do we need
|
||||
TResources resources; //how many resources do we need
|
||||
Goals::TSubgoal goal; //what for (build, gather army etc...)
|
||||
};
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
bool notifyGoalCompleted(Goals::TSubgoal goal) override;
|
||||
|
||||
protected: //not-const actions only for AI
|
||||
virtual void reserveResoures(const TResources & res, Goals::TSubgoal goal = Goals::TSubgoal());
|
||||
virtual void reserveResources(const TResources & res, Goals::TSubgoal goal = Goals::TSubgoal());
|
||||
virtual bool updateGoal(Goals::TSubgoal goal); //new goal must have same properties but different priority
|
||||
virtual bool tryPush(const ResourceObjective &o);
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ void VCAI::objectPropertyChanged(const SetObjectProperty * sop)
|
||||
auto obj = myCb->getObj(sop->id, false);
|
||||
if(obj)
|
||||
{
|
||||
addVisitableObj(obj); // TODO: Remove once save compatability broken. In past owned objects were removed from this set
|
||||
addVisitableObj(obj); // TODO: Remove once save compatibility broken. In past owned objects were removed from this set
|
||||
vstd::erase_if_present(alreadyVisited, obj);
|
||||
}
|
||||
}
|
||||
@@ -682,7 +682,7 @@ void VCAI::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID cha
|
||||
status.addQuery(askID, boost::str(boost::format("Teleport dialog query with %d exits")
|
||||
% exits.size()));
|
||||
|
||||
int choosenExit = -1;
|
||||
int chosenExit = -1;
|
||||
if(impassable)
|
||||
{
|
||||
knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
|
||||
@@ -691,14 +691,14 @@ void VCAI::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID cha
|
||||
{
|
||||
auto neededExit = std::make_pair(destinationTeleport, destinationTeleportPos);
|
||||
if(destinationTeleport != ObjectInstanceID() && vstd::contains(exits, neededExit))
|
||||
choosenExit = vstd::find_pos(exits, neededExit);
|
||||
chosenExit = vstd::find_pos(exits, neededExit);
|
||||
}
|
||||
|
||||
for(auto exit : exits)
|
||||
{
|
||||
if(status.channelProbing() && exit.first == destinationTeleport)
|
||||
{
|
||||
choosenExit = vstd::find_pos(exits, exit);
|
||||
chosenExit = vstd::find_pos(exits, exit);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@@ -716,7 +716,7 @@ void VCAI::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID cha
|
||||
|
||||
requestActionASAP([=]()
|
||||
{
|
||||
answerQuery(askID, choosenExit);
|
||||
answerQuery(askID, chosenExit);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ void VCAI::mainLoop()
|
||||
while (possibleGoals.size())
|
||||
{
|
||||
//allow assign goals to heroes with 0 movement, but don't realize them
|
||||
//maybe there are beter ones left
|
||||
//maybe there are better ones left
|
||||
|
||||
auto bestGoal = fh->chooseSolution(possibleGoals);
|
||||
if (bestGoal->hero) //lock this hero to fulfill goal
|
||||
@@ -1543,7 +1543,7 @@ void VCAI::completeGoal(Goals::TSubgoal goal)
|
||||
auto it = lockedHeroes.find(h);
|
||||
if(it != lockedHeroes.end())
|
||||
{
|
||||
if(it->second == goal || it->second->fulfillsMe(goal)) //FIXME this is overspecified, fulfillsMe shoudl be complete
|
||||
if(it->second == goal || it->second->fulfillsMe(goal)) //FIXME this is overspecified, fulfillsMe should be complete
|
||||
{
|
||||
logAi->debug(goal->completeMessage());
|
||||
lockedHeroes.erase(it); //goal fulfilled, free hero
|
||||
@@ -1735,7 +1735,7 @@ const CGObjectInstance * VCAI::lookForArt(ArtifactID aid) const
|
||||
|
||||
return nullptr;
|
||||
|
||||
//TODO what if more than one artifact is available? return them all or some slection criteria
|
||||
//TODO what if more than one artifact is available? return them all or some selection criteria
|
||||
}
|
||||
|
||||
bool VCAI::isAccessible(const int3 & pos) const
|
||||
@@ -2110,7 +2110,7 @@ void VCAI::tryRealize(Goals::Trade & g) //trade
|
||||
if(ah->freeResources()[g.resID] >= g.value) //goal is already fulfilled. Why we need this check, anyway?
|
||||
throw goalFulfilledException(sptr(g));
|
||||
|
||||
int accquiredResources = 0;
|
||||
int acquiredResources = 0;
|
||||
if(const CGObjectInstance * obj = cb->getObj(ObjectInstanceID(g.objid), false))
|
||||
{
|
||||
if(const auto * m = dynamic_cast<const IMarket*>(obj))
|
||||
@@ -2130,8 +2130,8 @@ void VCAI::tryRealize(Goals::Trade & g) //trade
|
||||
if (toGive) //don't try to sell 0 resources
|
||||
{
|
||||
cb->trade(m, EMarketMode::RESOURCE_RESOURCE, res, GameResID(g.resID), toGive);
|
||||
accquiredResources = static_cast<int>(toGet * (it->resVal / toGive));
|
||||
logAi->debug("Traded %d of %s for %d of %s at %s", toGive, res, accquiredResources, g.resID, obj->getObjectName());
|
||||
acquiredResources = static_cast<int>(toGet * (it->resVal / toGive));
|
||||
logAi->debug("Traded %d of %s for %d of %s at %s", toGive, res, acquiredResources, g.resID, obj->getObjectName());
|
||||
}
|
||||
if (ah->freeResources()[g.resID] >= g.value)
|
||||
throw goalFulfilledException(sptr(g)); //we traded all we needed
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
//std::vector<const CGObjectInstance *> visitedThisWeek; //only OPWs
|
||||
std::map<HeroPtr, std::set<const CGTownInstance *>> townVisitsThisWeek;
|
||||
|
||||
//part of mainLoop, but accessible from outisde
|
||||
//part of mainLoop, but accessible from outside
|
||||
std::vector<Goals::TSubgoal> basicGoals;
|
||||
Goals::TGoalVec goalsToRemove;
|
||||
Goals::TGoalVec goalsToAdd;
|
||||
|
||||
Reference in New Issue
Block a user