@@ -3355,14 +3355,20 @@ pair<int,int> CvBuilderTaskingAI::ScorePlotBuild(CvPlot* pPlot, ImprovementTypes
3355
3355
if (!pAdjacentOwningCity || pAdjacentOwningCity->IsRazing ())
3356
3356
continue ;
3357
3357
3358
- int iNewAdjacentYield = 0 ;
3358
+ int iNewAdjacentWorkedYield = 0 ;
3359
+ int iNewAdjacentUnworkedYield = 0 ;
3360
+
3361
+ bool bWorkingAdjacent = pAdjacentOwningCity->GetCityCitizens ()->IsWorkingPlot (pAdjacentPlot);
3359
3362
3360
3363
// How much extra yield we give to adjacent tiles with a certain terrain
3361
3364
if (pAdjacentPlot->getTerrainType () != NO_TERRAIN)
3362
3365
{
3363
3366
int iAdjacentTerrainYieldChange = pkImprovementInfo ? pkImprovementInfo->GetAdjacentTerrainYieldChanges (pAdjacentPlot->getTerrainType (), eYield) : 0 ;
3364
3367
if (iAdjacentTerrainYieldChange != 0 )
3365
- iNewAdjacentYield += iAdjacentTerrainYieldChange;
3368
+ if (bWorkingAdjacent)
3369
+ iNewAdjacentWorkedYield += iAdjacentTerrainYieldChange;
3370
+ else
3371
+ iNewAdjacentUnworkedYield += iAdjacentTerrainYieldChange;
3366
3372
}
3367
3373
3368
3374
ImprovementTypes eAdjacentImprovement = GetPlannedImprovementInPlot (pAdjacentPlot, sState );
@@ -3382,14 +3388,20 @@ pair<int,int> CvBuilderTaskingAI::ScorePlotBuild(CvPlot* pPlot, ImprovementTypes
3382
3388
3383
3389
int iDeltaTruncatedYield = (fCurrentAdjacentImprovementYield + fAdjacentImprovementYield ).Truncate () - fCurrentAdjacentImprovementYield .Truncate ();
3384
3390
if (iDeltaTruncatedYield != 0 )
3385
- iNewAdjacentYield += iDeltaTruncatedYield;
3391
+ if (bWorkingAdjacent)
3392
+ iNewAdjacentWorkedYield += iDeltaTruncatedYield;
3393
+ else
3394
+ iNewAdjacentUnworkedYield += iDeltaTruncatedYield;
3386
3395
3387
3396
// How much extra yield an adjacent improvement will get if we create a resource
3388
3397
if (eResourceFromImprovement != NO_RESOURCE)
3389
3398
{
3390
3399
int iAdjacentResourceYieldChanges = pkAdjacentImprovementInfo->GetAdjacentResourceYieldChanges (eResourceFromImprovement, eYield);
3391
3400
if (iAdjacentResourceYieldChanges != 0 )
3392
- iNewAdjacentYield += iAdjacentResourceYieldChanges;
3401
+ if (bWorkingAdjacent)
3402
+ iNewAdjacentWorkedYield += iAdjacentResourceYieldChanges;
3403
+ else
3404
+ iNewAdjacentUnworkedYield += iAdjacentResourceYieldChanges;
3393
3405
}
3394
3406
3395
3407
// How much extra yield an adjacent improvement will get if we create a feature (or keep the one that's here)
@@ -3398,15 +3410,19 @@ pair<int,int> CvBuilderTaskingAI::ScorePlotBuild(CvPlot* pPlot, ImprovementTypes
3398
3410
FeatureTypes eNewFeature = eFeatureFromImprovement != NO_FEATURE ? eFeatureFromImprovement : eFeature;
3399
3411
int iAdjacentFeatureYieldChanges = pkAdjacentImprovementInfo->GetAdjacentFeatureYieldChanges (eNewFeature, eYield);
3400
3412
if (iAdjacentFeatureYieldChanges != 0 )
3401
- iNewAdjacentYield += iAdjacentFeatureYieldChanges;
3413
+ if (bWorkingAdjacent)
3414
+ iNewAdjacentWorkedYield += iAdjacentFeatureYieldChanges;
3415
+ else
3416
+ iNewAdjacentUnworkedYield += iAdjacentFeatureYieldChanges;
3402
3417
}
3403
3418
}
3404
3419
}
3405
3420
3406
- if (iNewAdjacentYield != 0 )
3421
+ if (iNewAdjacentWorkedYield != 0 || iNewAdjacentUnworkedYield != 0 )
3407
3422
{
3408
3423
int iAdjacentCityYieldModifier = pAdjacentOwningCity ? GetYieldCityModifierTimes100 (pAdjacentOwningCity, m_pPlayer, eYield) : 100 ;
3409
- iSecondaryScore += (iNewAdjacentYield * iYieldModifier * iAdjacentCityYieldModifier) / 100 ;
3424
+ iSecondaryScore += (iNewAdjacentWorkedYield * iYieldModifier * iAdjacentCityYieldModifier) / 100 ;
3425
+ iPotentialScore += (iNewAdjacentUnworkedYield * iYieldModifier * iAdjacentCityYieldModifier) / 100 ;
3410
3426
}
3411
3427
}
3412
3428
}
@@ -3519,7 +3535,7 @@ pair<int,int> CvBuilderTaskingAI::ScorePlotBuild(CvPlot* pPlot, ImprovementTypes
3519
3535
if (eOldImprovement != NO_IMPROVEMENT)
3520
3536
{
3521
3537
CvImprovementEntry* pkOldImprovementInfo = GC.getImprovementInfo (eOldImprovement);
3522
- if (pkOldImprovementInfo && (pkOldImprovementInfo->IsConnectsResource (eResource) || pkOldImprovementInfo->GetResourceFromImprovement () == eResourceFromImprovement ))
3538
+ if (pkOldImprovementInfo && (pkOldImprovementInfo->IsConnectsResource (eResource) || pkOldImprovementInfo->GetResourceFromImprovement () == eResource ))
3523
3539
iExtraResource -= iResourceAmount;
3524
3540
3525
3541
}
@@ -3562,7 +3578,7 @@ pair<int,int> CvBuilderTaskingAI::ScorePlotBuild(CvPlot* pPlot, ImprovementTypes
3562
3578
}
3563
3579
int iTotalNumResource = GC.getMap ().getNumResources (eConnectedResource);
3564
3580
if (bCreatesResource)
3565
- iTotalNumResource += iExtraResource ;
3581
+ iTotalNumResource += iResourceAmount ;
3566
3582
3567
3583
int iCurrentMonopolyPercent = 0 ;
3568
3584
int iFutureMonopolyPercent = 0 ;
@@ -3582,7 +3598,8 @@ pair<int,int> CvBuilderTaskingAI::ScorePlotBuild(CvPlot* pPlot, ImprovementTypes
3582
3598
if (pkConnectedResource->getResourceUsage () == RESOURCEUSAGE_STRATEGIC)
3583
3599
iStrategicThreshold = /* 25*/ GD_INT_GET (STRATEGIC_RESOURCE_MONOPOLY_THRESHOLD);
3584
3600
3585
- bool bCanReachGlobalMonopoly = iFutureMonopolyPercent > 50 || m_pPlayer->GetPlayerTraits ()->IsImportsCountTowardsMonopolies () || (2 * (m_pPlayer->getResourceInOwnedPlots (eConnectedResource) + iResourceFromMinors) > iTotalNumResource);
3601
+ bool bCanReachGlobalMonopoly = iFutureMonopolyPercent > iGlobalThreshold || m_pPlayer->GetPlayerTraits ()->IsImportsCountTowardsMonopolies () || (100 * (m_pPlayer->getResourceInOwnedPlots (eConnectedResource) + iResourceFromMinors) > iGlobalThreshold * iTotalNumResource);
3602
+ bool bCanReachStrategicMonopoly = iStrategicThreshold != 0 && (iFutureMonopolyPercent > iStrategicThreshold || m_pPlayer->GetPlayerTraits ()->IsImportsCountTowardsMonopolies () || (100 * (m_pPlayer->getResourceInOwnedPlots (eConnectedResource) + iResourceFromMinors) > iStrategicThreshold * iTotalNumResource));
3586
3603
3587
3604
if (iCurrentMonopolyPercent <= iGlobalThreshold)
3588
3605
{
@@ -3603,6 +3620,10 @@ pair<int,int> CvBuilderTaskingAI::ScorePlotBuild(CvPlot* pPlot, ImprovementTypes
3603
3620
// We can get a global monopoly eventually
3604
3621
iPotentialScore += 2000 ;
3605
3622
}
3623
+ else if (bCanReachStrategicMonopoly)
3624
+ {
3625
+ iPotentialScore += 1000 ;
3626
+ }
3606
3627
}
3607
3628
}
3608
3629
}
0 commit comments