Skip to content

Commit

Permalink
x100 approach scores, improve selection & fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveVision committed Sep 26, 2023
1 parent f5d4e4a commit a2d641f
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 298 deletions.
29 changes: 23 additions & 6 deletions CvGameCoreDLL_Expansion2/CvDealClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6737,7 +6737,7 @@ bool CvGameDeals::IsReceivingItemsFromPlayer(PlayerTypes ePlayer, PlayerTypes eO
return false;
}

int CvGameDeals::GetDealValueWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, bool bConsiderDuration)
int CvGameDeals::GetDealValueWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, bool bEmbargoEvaluation)
{
DealList::iterator iter;
DealList::iterator end = m_CurrentDeals.end();
Expand All @@ -6753,7 +6753,7 @@ int CvGameDeals::GetDealValueWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherP
if (iEndTurn <= GC.getGame().getGameTurn())
continue;

if (bConsiderDuration)
if (!bEmbargoEvaluation)
{
iVal += iter->GetGoldPerTurnTrade(eOtherPlayer) * (iter->GetEndTurn() - GC.getGame().getGameTurn());
}
Expand All @@ -6771,7 +6771,7 @@ int CvGameDeals::GetDealValueWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherP
if (pkResourceInfo == NULL || pkResourceInfo->getResourceUsage() == RESOURCEUSAGE_BONUS)
continue;

if (bConsiderDuration)
if (!bEmbargoEvaluation)
{
iVal += iter->GetNumResourcesInDeal(eOtherPlayer, eResource) * 5 * (iter->GetEndTurn() - GC.getGame().getGameTurn());
}
Expand All @@ -6781,12 +6781,29 @@ int CvGameDeals::GetDealValueWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherP
}
}

iVal += iter->IsOpenBordersTrade(eOtherPlayer) ? 10 * iAvgDealDuration : 0;
iVal += iter->IsOpenBordersTrade(ePlayer) ? 5 * iAvgDealDuration : 0;
iVal += iter->IsDefensivePactTrade(eOtherPlayer) ? 50 * iAvgDealDuration : 0;
if (!bEmbargoEvaluation)
{
iVal += iter->IsOpenBordersTrade(eOtherPlayer) ? 5 * iAvgDealDuration : 0;
iVal += iter->IsOpenBordersTrade(ePlayer) ? 5 * iAvgDealDuration : 0;
iVal += iter->IsDefensivePactTrade(eOtherPlayer) ? 15 * iAvgDealDuration : 0;
}
else
{
iVal += iter->IsOpenBordersTrade(eOtherPlayer) ? 10 * iAvgDealDuration : 0;
iVal += iter->IsOpenBordersTrade(ePlayer) ? 5 * iAvgDealDuration : 0;
iVal += iter->IsDefensivePactTrade(eOtherPlayer) ? 50 * iAvgDealDuration : 0;
}
}
}

// Modify by game speed for roughly consistent valuation across all game speeds
CvGameSpeedInfo *pkStdSpeedInfo = GC.getGameSpeedInfo((GameSpeedTypes)GD_INT_GET(STANDARD_GAMESPEED));
if (pkStdSpeedInfo)
{
iVal *= pkStdSpeedInfo->GetDealDuration();
iVal /= GC.getGame().GetDealDuration();
}

return iVal;
}

Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvDealClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class CvGameDeals
uint GetNumHistoricDealsWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, uint iMaxCount = UINT_MAX);
std::vector<CvDeal*> GetRenewableDealsWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, uint iMaxCount = UINT_MAX, bool bOnlyCheckedDeals = false);
bool IsReceivingItemsFromPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, bool bMutual);
int GetDealValueWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, bool bConsiderDuration = true);
int GetDealValueWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, bool bEmbargoEvaluation);
int GetTurnsBeforeRegainingLuxury(PlayerTypes ePlayer, ResourceTypes eResource);
int GetDealGPTLostFromWar(PlayerTypes ePlayer, PlayerTypes eOtherPlayer);

Expand Down
Loading

0 comments on commit a2d641f

Please sign in to comment.