mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 20:55:44 +00:00
Fix cached Shardok bridge path checks (#8782)
This commit is contained in:
@@ -429,7 +429,7 @@ auto WaterCrossingTiles(
|
||||
terr->mutable_modifier().mutable_bridge().mutate_integrity(100.0);
|
||||
terr->mutable_modifier().mutable_fire().mutate_present(false);
|
||||
|
||||
auto hash = ActionPointDistancesCache::GetMapId(mapCopy);
|
||||
const MapId hash = RecomputeModifierHash(mapCopy.Get());
|
||||
|
||||
if (const auto *distances = apdCache->GetRaw(mapCopy, hash, battalionType, false);
|
||||
distances->Distance(origin, destination) != ActionPointDistances::IMPOSSIBLE) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "src/main/cpp/net/eagle0/common/FilesystemUtils.hpp"
|
||||
#include "src/main/cpp/net/eagle0/common/RandomGenerator.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/ai/AIConfig.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/ai/AIWaterCrossingCalculator.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/ai/ShardokAIClient.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/ai/TranspositionTable.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/ai_testing_common/AIClientFactory.hpp"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "src/main/cpp/net/eagle0/shardok/library/ShardokEngine.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/library/action_point_distances/ActionPointDistancesCache.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/library/fb_helpers/GameStateHelpers.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/library/fb_helpers/HexMapHelpers.hpp"
|
||||
#include "src/main/cpp/net/eagle0/shardok/util/MapLoader.hpp"
|
||||
#include "src/test/cpp/net/eagle0/shardok/library/GameStart_test_data.hpp"
|
||||
|
||||
@@ -158,6 +160,23 @@ TEST_F(RealBattleDecisionRegressionTest, DoesNotChooseKingsLoyalistsMageDistantF
|
||||
chosenCommand->GetActorUnitId() == 3);
|
||||
}
|
||||
|
||||
TEST_F(RealBattleDecisionRegressionTest, ChipingiaWaterCrossingFindsUsefulBridgeTiles) {
|
||||
// The custom-battle "Rivers" scenario puts its engineer on the southeast side of
|
||||
// Chipingia and the defending units by the northern castles.
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
fbb.ForceDefaults(true);
|
||||
const auto mapOffset = fb::ConvertHexMapProto(fbb, LoadMap("Chipingia"));
|
||||
const auto* map = flatbuffers::GetTemporaryPointer(fbb, mapOffset);
|
||||
const auto apdCache = std::make_shared<ActionPointDistancesCache>();
|
||||
const auto heavyInfantry = settings->GetGetter().GetBattalionType(
|
||||
net::eagle0::shardok::storage::fb::BattalionTypeId_HEAVY_INFANTRY);
|
||||
|
||||
const auto crossingTiles =
|
||||
WaterCrossingTiles(Coords(6, 13), Coords(0, 9), map, apdCache, heavyInfantry);
|
||||
|
||||
EXPECT_FALSE(crossingTiles.empty());
|
||||
}
|
||||
|
||||
TEST_F(RealBattleDecisionRegressionTest, RegiaAtSigkarlFirstAttackerTurnDoesNotFlee) {
|
||||
std::vector<Unit> units{
|
||||
MakeUnit(
|
||||
|
||||
Reference in New Issue
Block a user