Skip to content

Commit

Permalink
small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteroi authored and RecursiveVision committed Dec 15, 2023
1 parent a6368c3 commit 5ca6ac6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvAStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ int PathValid(const CvAStarNode* parent, const CvAStarNode* node, const SPathFin
//if there are no enemies here or they have been killed in tactsim (hypothetically)
if (!kToNodeCacheData.bIsVisibleEnemyCombatUnit && !kToNodeCacheData.bIsVisibleEnemyUnit && !kToNodeCacheData.bIsVisibleNeutralCombatUnit)
{
if (!canEnterTerritoryAndTerrain(pUnit, pToPlot, kToNodeCacheData.iMoveFlags))
if (!canEnterTerritoryAndTerrain(pUnit, pToPlot, kToNodeCacheData.iMoveFlags) || (kToNodeCacheData.bIsNonEnemyCity && !pUnit->IsCivilianUnit()))
return FALSE;
}
else
Expand Down
4 changes: 2 additions & 2 deletions CvGameCoreDLL_Expansion2/CvDangerPlots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ int CvDangerPlotContents::GetDanger(const CvUnit* pUnit, const UnitIdContainer&

CvCity* pFriendlyCity = m_pPlot->isFriendlyCity(*pUnit) ? m_pPlot->getPlotCity() : NULL;

// Civilians can be captured - unless they would need to be embarked on this plot
if (!pUnit->IsCombatUnit() && pUnit->isNativeDomain(m_pPlot))
// Civilians can be captured
if (pUnit->IsCivilianUnit())
{
// If plot contains an enemy unit, mark it as max danger
if (m_pPlot->isEnemyUnit(pUnit->getOwner(),true,true))
Expand Down
4 changes: 1 addition & 3 deletions CvGameCoreDLL_Expansion2/CvHomelandAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,6 @@ bool CvHomelandAI::SendUnitGift(DomainTypes eDomain)
if (eBestGiftTarget != NO_PLAYER)
{
vector<int> vUnitIDs;
bool bFoundOne = false;
int iLoop = 0;
for (CvUnit* pUnit = m_pPlayer->firstUnit(&iLoop); pUnit != NULL; pUnit = m_pPlayer->nextUnit(&iLoop))
{
Expand Down Expand Up @@ -1313,11 +1312,10 @@ bool CvHomelandAI::SendUnitGift(DomainTypes eDomain)
}

vUnitIDs.push_back(pUnit->GetID());
bFoundOne = true;
}
}
}
if (bFoundOne)
if (!vUnitIDs.empty())
{
CvUnit* pGiftedUnit = NULL;
int GiftedUnitID = -1;
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4780,7 +4780,7 @@ bool CvPlot::isNeutralUnit(PlayerTypes ePlayer, bool bCombat, bool bCheckVisibil
if(pLoopUnit && !pLoopUnit->isInvisible(eTeam, false) && !pLoopUnit->IsDead())
{
//airplanes not included
if (bCombat && (!pLoopUnit->IsCanDefend() || !pLoopUnit->isNativeDomain(this)))
if (bCombat && !pLoopUnit->IsCanDefend())
continue;

if (bIgnoreMinors && GET_PLAYER(pLoopUnit->getOwner()).isMinorCiv())
Expand Down
17 changes: 13 additions & 4 deletions CvGameCoreDLL_Expansion2/CvTacticalAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7317,14 +7317,14 @@ void ScoreAttack(const CvTacticalPlot& tactPlot, const CvUnit* pUnit, const CvTa
}
else
{
iExtraScore += 300; //capturing a city is important
iExtraScore += 600; //capturing a city is important
result.eAssignmentType = A_MELEEKILL;
}
}
else //enemy unit killed
{
//tbd: same bonus for melee kill and range kill? do we have a preference? what about move-after-attack?
iExtraScore += 30;
iExtraScore += 200;

if (pTestPlot->getNumUnits() > 1 && !pTestPlot->isNeutralUnit(pUnit->getOwner(), false, false))
iExtraScore += 20; //even more points for a double kill
Expand Down Expand Up @@ -9127,8 +9127,8 @@ bool CvTacticalPosition::addFinishMovesIfAcceptable(bool bEarlyFinish)
if (!pInitial)
return false; //something wrong

//if the unit is blocked but has movement left and can flee, let's assume that is ok. also if we never moved it.
if (unit.eLastAssignment == A_BLOCKED && (unit.iMovesLeft>GC.getMOVE_DENOMINATOR() || unit.iPlotIndex==pInitial->iToPlotIndex))
//if the unit is blocked but has movement left and can flee, let's assume that is ok
if (unit.eLastAssignment == A_BLOCKED && unit.iMovesLeft>GC.getMOVE_DENOMINATOR())
continue;

//if we have a restart pending, that can also be ok if we're not planning to stay
Expand Down Expand Up @@ -9157,6 +9157,15 @@ bool CvTacticalPosition::addFinishMovesIfAcceptable(bool bEarlyFinish)
return false;
}

//try to enforce some sort of sparsity, we should use only the minimum amount of units.
//so give a bonus for unmoved units. especially important in earlyFinish situations with many units.
for (size_t i = 0; i < availableUnits.size(); i++)
{
const SUnitStats& unit = availableUnits[i];
if (unit.eLastAssignment == A_INITIAL)
iTotalScore += 30;
}

//scores look good and target was killed, we're done
if (bEarlyFinish)
{
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvTacticalAnalysisMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ eTacticalPosture CvTacticalDominanceZone::SelectPostureSingleZone(int iDominance
}
case TACTICAL_TERRITORY_FRIENDLY:
{
m_ePosture = (eOverallDominance == TACTICAL_DOMINANCE_ENEMY) ? TACTICAL_POSTURE_HEDGEHOG : TACTICAL_POSTURE_COUNTERATTACK;
m_ePosture = TACTICAL_POSTURE_COUNTERATTACK;
break;
}
}
Expand Down

0 comments on commit 5ca6ac6

Please sign in to comment.