Add AI MaxResourceCellsToCheck for refinery placement decision

This commit is contained in:
reaperrr
2015-09-28 22:50:23 +02:00
parent 5ad9eb852c
commit 2b0920398f

View File

@@ -74,6 +74,9 @@ namespace OpenRA.Mods.Common.AI
"for StructureProductionResumeDelay before retrying.")] "for StructureProductionResumeDelay before retrying.")]
public readonly int MaximumFailedPlacementAttempts = 3; public readonly int MaximumFailedPlacementAttempts = 3;
[Desc("How many randomly chosen cells with resources to check when deciding refinery placement.")]
public readonly int MaxResourceCellsToCheck = 3;
[Desc("Delay (in ticks) until rechecking for new BaseProviders.")] [Desc("Delay (in ticks) until rechecking for new BaseProviders.")]
public readonly int CheckForNewBasesDelay = 1500; public readonly int CheckForNewBasesDelay = 1500;
@@ -500,11 +503,11 @@ namespace OpenRA.Mods.Common.AI
// Try and place the refinery near a resource field // Try and place the refinery near a resource field
var nearbyResources = Map.FindTilesInCircle(baseCenter, Info.MaxBaseRadius) var nearbyResources = Map.FindTilesInCircle(baseCenter, Info.MaxBaseRadius)
.Where(a => resourceTypeIndices.Get(Map.GetTerrainIndex(a))) .Where(a => resourceTypeIndices.Get(Map.GetTerrainIndex(a)))
.Shuffle(Random).ToList(); .Shuffle(Random).Take(Info.MaxResourceCellsToCheck);
if (nearbyResources.Count > 0) foreach (var r in nearbyResources)
{ {
var found = findPos(nearbyResources.First(), baseCenter, 0, Info.MaxBaseRadius); var found = findPos(r, baseCenter, 0, Info.MaxBaseRadius);
if (found != null) if (found != null)
return found; return found;
} }