mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-11 11:31:52 +02:00
Merge pull request #5229 from IvanSavenko/ai_optimize_test
[1.6.3] AI performance-related changes
This commit is contained in:
commit
3d384b2ec3
@ -285,8 +285,8 @@ void AIGateway::tileRevealed(const std::unordered_set<int3> & pos)
|
||||
addVisitableObj(obj);
|
||||
}
|
||||
|
||||
if (nullkiller->settings->isUpdateHitmapOnTileReveal())
|
||||
nullkiller->dangerHitMap->reset();
|
||||
if (nullkiller->settings->isUpdateHitmapOnTileReveal() && !pos.empty())
|
||||
nullkiller->dangerHitMap->resetTileOwners();
|
||||
}
|
||||
|
||||
void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query)
|
||||
@ -389,9 +389,10 @@ void AIGateway::objectRemoved(const CGObjectInstance * obj, const PlayerColor &
|
||||
}
|
||||
|
||||
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
|
||||
{
|
||||
nullkiller->dangerHitMap->reset();
|
||||
}
|
||||
nullkiller->dangerHitMap->resetHitmap();
|
||||
|
||||
if(obj->ID == Obj::TOWN)
|
||||
nullkiller->dangerHitMap->resetTileOwners();
|
||||
}
|
||||
|
||||
void AIGateway::showHillFortWindow(const CGObjectInstance * object, const CGHeroInstance * visitor)
|
||||
@ -507,7 +508,7 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
|
||||
else if(relations == PlayerRelations::SAME_PLAYER && obj->ID == Obj::TOWN)
|
||||
{
|
||||
// reevaluate defence for a new town
|
||||
nullkiller->dangerHitMap->reset();
|
||||
nullkiller->dangerHitMap->resetHitmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1246,7 +1247,7 @@ void AIGateway::addVisitableObj(const CGObjectInstance * obj)
|
||||
|
||||
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
|
||||
{
|
||||
nullkiller->dangerHitMap->reset();
|
||||
nullkiller->dangerHitMap->resetHitmap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
|
||||
PathfinderSettings ps;
|
||||
|
||||
ps.scoutTurnDistanceLimit = ps.mainTurnDistanceLimit = ai->settings->getMainHeroTurnDistanceLimit();
|
||||
ps.scoutTurnDistanceLimit = ps.mainTurnDistanceLimit = ai->settings->getThreatTurnDistanceLimit();
|
||||
ps.useHeroChain = false;
|
||||
|
||||
ai->pathfinder->updatePaths(pair.second, ps);
|
||||
@ -345,10 +345,4 @@ std::set<const CGObjectInstance *> DangerHitMapAnalyzer::getOneTurnAccessibleObj
|
||||
return result;
|
||||
}
|
||||
|
||||
void DangerHitMapAnalyzer::reset()
|
||||
{
|
||||
hitMapUpToDate = false;
|
||||
tileOwnersUpToDate = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
const HitMapNode & getObjectThreat(const CGObjectInstance * obj) const;
|
||||
const HitMapNode & getTileThreat(const int3 & tile) const;
|
||||
std::set<const CGObjectInstance *> getOneTurnAccessibleObjects(const CGHeroInstance * enemy) const;
|
||||
void reset();
|
||||
void resetHitmap() {hitMapUpToDate = false;}
|
||||
void resetTileOwners() { tileOwnersUpToDate = false; }
|
||||
PlayerColor getTileOwner(const int3 & tile) const;
|
||||
const CGTownInstance * getClosestTown(const int3 & tile) const;
|
||||
|
@ -229,7 +229,7 @@ void Nullkiller::resetAiState()
|
||||
lockedResources = TResources();
|
||||
scanDepth = ScanDepth::MAIN_FULL;
|
||||
lockedHeroes.clear();
|
||||
dangerHitMap->reset();
|
||||
dangerHitMap->resetHitmap();
|
||||
useHeroChain = true;
|
||||
objectClusterizer->reset();
|
||||
|
||||
|
@ -28,6 +28,7 @@ namespace NKAI
|
||||
: maxRoamingHeroes(8),
|
||||
mainHeroTurnDistanceLimit(10),
|
||||
scoutHeroTurnDistanceLimit(5),
|
||||
threatTurnDistanceLimit(5),
|
||||
maxGoldPressure(0.3f),
|
||||
retreatThresholdRelative(0.3),
|
||||
retreatThresholdAbsolute(10000),
|
||||
|
@ -24,6 +24,7 @@ namespace NKAI
|
||||
int maxRoamingHeroes;
|
||||
int mainHeroTurnDistanceLimit;
|
||||
int scoutHeroTurnDistanceLimit;
|
||||
int threatTurnDistanceLimit;
|
||||
int maxPass;
|
||||
int maxPriorityPass;
|
||||
int pathfinderBucketsCount;
|
||||
@ -52,6 +53,7 @@ namespace NKAI
|
||||
int getMaxRoamingHeroes() const { return maxRoamingHeroes; }
|
||||
int getMainHeroTurnDistanceLimit() const { return mainHeroTurnDistanceLimit; }
|
||||
int getScoutHeroTurnDistanceLimit() const { return scoutHeroTurnDistanceLimit; }
|
||||
int getThreatTurnDistanceLimit() const { return threatTurnDistanceLimit; }
|
||||
int getPathfinderBucketsCount() const { return pathfinderBucketsCount; }
|
||||
int getPathfinderBucketSize() const { return pathfinderBucketSize; }
|
||||
bool isObjectGraphAllowed() const { return allowObjectGraph; }
|
||||
|
@ -38,13 +38,14 @@
|
||||
"maxPriorityPass" : 10,
|
||||
"mainHeroTurnDistanceLimit" : 10,
|
||||
"scoutHeroTurnDistanceLimit" : 5,
|
||||
"threatTurnDistanceLimit" : 1,
|
||||
"maxGoldPressure" : 0.3,
|
||||
"updateHitmapOnTileReveal" : false,
|
||||
"updateHitmapOnTileReveal" : true,
|
||||
"useTroopsFromGarrisons" : true,
|
||||
"openMap": true,
|
||||
"allowObjectGraph": true,
|
||||
"pathfinderBucketsCount" : 4, // old value: 3,
|
||||
"pathfinderBucketSize" : 8, // old value: 7,
|
||||
"allowObjectGraph": false,
|
||||
"pathfinderBucketsCount" : 3,
|
||||
"pathfinderBucketSize" : 7,
|
||||
"retreatThresholdRelative" : 0,
|
||||
"retreatThresholdAbsolute" : 0,
|
||||
"safeAttackRatio" : 1.1,
|
||||
@ -58,13 +59,14 @@
|
||||
"maxPriorityPass" : 10,
|
||||
"mainHeroTurnDistanceLimit" : 10,
|
||||
"scoutHeroTurnDistanceLimit" : 5,
|
||||
"threatTurnDistanceLimit" : 4,
|
||||
"maxGoldPressure" : 0.3,
|
||||
"updateHitmapOnTileReveal" : false,
|
||||
"updateHitmapOnTileReveal" : true,
|
||||
"useTroopsFromGarrisons" : true,
|
||||
"openMap": true,
|
||||
"allowObjectGraph": true,
|
||||
"pathfinderBucketsCount" : 4, // old value: 3,
|
||||
"pathfinderBucketSize" : 8, // old value: 7,
|
||||
"allowObjectGraph": false,
|
||||
"pathfinderBucketsCount" : 3,
|
||||
"pathfinderBucketSize" : 7,
|
||||
"retreatThresholdRelative" : 0.1,
|
||||
"retreatThresholdAbsolute" : 5000,
|
||||
"safeAttackRatio" : 1.1,
|
||||
@ -78,13 +80,14 @@
|
||||
"maxPriorityPass" : 10,
|
||||
"mainHeroTurnDistanceLimit" : 10,
|
||||
"scoutHeroTurnDistanceLimit" : 5,
|
||||
"threatTurnDistanceLimit" : 5,
|
||||
"maxGoldPressure" : 0.3,
|
||||
"updateHitmapOnTileReveal" : false,
|
||||
"updateHitmapOnTileReveal" : true,
|
||||
"useTroopsFromGarrisons" : true,
|
||||
"openMap": true,
|
||||
"allowObjectGraph": true,
|
||||
"pathfinderBucketsCount" : 4, // old value: 3,
|
||||
"pathfinderBucketSize" : 8, // old value: 7,
|
||||
"allowObjectGraph": false,
|
||||
"pathfinderBucketsCount" : 3,
|
||||
"pathfinderBucketSize" : 7,
|
||||
"retreatThresholdRelative" : 0.3,
|
||||
"retreatThresholdAbsolute" : 10000,
|
||||
"safeAttackRatio" : 1.1,
|
||||
@ -98,13 +101,14 @@
|
||||
"maxPriorityPass" : 10,
|
||||
"mainHeroTurnDistanceLimit" : 10,
|
||||
"scoutHeroTurnDistanceLimit" : 5,
|
||||
"threatTurnDistanceLimit" : 5,
|
||||
"maxGoldPressure" : 0.3,
|
||||
"updateHitmapOnTileReveal" : false,
|
||||
"updateHitmapOnTileReveal" : true,
|
||||
"useTroopsFromGarrisons" : true,
|
||||
"openMap": true,
|
||||
"allowObjectGraph": true,
|
||||
"pathfinderBucketsCount" : 4, // old value: 3,
|
||||
"pathfinderBucketSize" : 8, // old value: 7,
|
||||
"allowObjectGraph": false,
|
||||
"pathfinderBucketsCount" : 3,
|
||||
"pathfinderBucketSize" : 7,
|
||||
"retreatThresholdRelative" : 0.3,
|
||||
"retreatThresholdAbsolute" : 10000,
|
||||
"safeAttackRatio" : 1.1,
|
||||
@ -118,13 +122,14 @@
|
||||
"maxPriorityPass" : 10,
|
||||
"mainHeroTurnDistanceLimit" : 10,
|
||||
"scoutHeroTurnDistanceLimit" : 5,
|
||||
"threatTurnDistanceLimit" : 5,
|
||||
"maxGoldPressure" : 0.3,
|
||||
"updateHitmapOnTileReveal" : false,
|
||||
"updateHitmapOnTileReveal" : true,
|
||||
"useTroopsFromGarrisons" : true,
|
||||
"openMap": true,
|
||||
"allowObjectGraph": true,
|
||||
"pathfinderBucketsCount" : 4, // old value: 3,
|
||||
"pathfinderBucketSize" : 8, // old value: 7,
|
||||
"allowObjectGraph": false,
|
||||
"pathfinderBucketsCount" : 3,
|
||||
"pathfinderBucketSize" : 7,
|
||||
"retreatThresholdRelative" : 0.3,
|
||||
"retreatThresholdAbsolute" : 10000,
|
||||
"safeAttackRatio" : 1.1,
|
||||
|
@ -4115,12 +4115,10 @@ void CGameHandler::changeFogOfWar(const std::unordered_set<int3> &tiles, PlayerC
|
||||
|
||||
for (auto tile : observedTiles)
|
||||
vstd::erase_if_present (fow.tiles, tile);
|
||||
|
||||
if (fow.tiles.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
sendAndApply(fow);
|
||||
if (!fow.tiles.empty())
|
||||
sendAndApply(fow);
|
||||
}
|
||||
|
||||
const CGHeroInstance * CGameHandler::getVisitingHero(const CGObjectInstance *obj)
|
||||
|
@ -618,7 +618,9 @@ void PlayerMessageProcessor::cheatMapReveal(PlayerColor player, bool reveal)
|
||||
|
||||
fc.tiles.insert(hlp_tab, hlp_tab + lastUnc);
|
||||
delete [] hlp_tab;
|
||||
gameHandler->sendAndApply(fc);
|
||||
|
||||
if (!fc.tiles.empty())
|
||||
gameHandler->sendAndApply(fc);
|
||||
}
|
||||
|
||||
void PlayerMessageProcessor::cheatPuzzleReveal(PlayerColor player)
|
||||
|
Loading…
x
Reference in New Issue
Block a user