Beispiel #1
0
        public List <int> GenerateSingleTroopPlacement(
            CastleTargeter.CastlesTargetedInfo castleTargetingInfo,
            int valueToAssignPerNonTargetedCastle,
            TroopAllocationStrategy allocationStrategyForTargetedCastles,
            TroopAllocationStrategy allocationStrategyForNonTargetedCastles)
        {
            var numCastlesTargeted    = castleTargetingInfo.CastlesTargeted.Count;
            var numCastlesNotTargeted = castleTargetingInfo.CastlesNotTargeted.Count;
            var numTroopsToAllocateForNonTargetedCastles = valueToAssignPerNonTargetedCastle * numCastlesNotTargeted;
            var numTroopsToAllocateForTargetedCastles    = this._numTroops - numTroopsToAllocateForNonTargetedCastles;

            var troopPlacementForTargetedCastles    = new List <CastleTroopPlacement>();
            var troopPlacementForNonTargetedCastles = new List <CastleTroopPlacement>();

            switch (allocationStrategyForTargetedCastles)
            {
            case TroopAllocationStrategy.EvenDistribution:
                troopPlacementForTargetedCastles = this.AllocateTroopsToCastlesEvenly(
                    castleTargetingInfo.CastlesTargeted,
                    numTroopsToAllocateForTargetedCastles
                    );
                break;

            case TroopAllocationStrategy.ProportionalDistribution:
                troopPlacementForTargetedCastles = this.AllocateTroopsToCastlesProportionally(
                    castleTargetingInfo.CastlesTargeted,
                    numTroopsToAllocateForTargetedCastles
                    );
                break;
            }

            switch (allocationStrategyForNonTargetedCastles)
            {
            case TroopAllocationStrategy.EvenDistribution:
                troopPlacementForNonTargetedCastles = this.AllocateTroopsToCastlesEvenly(
                    castleTargetingInfo.CastlesNotTargeted,
                    numTroopsToAllocateForNonTargetedCastles
                    );
                break;

            case TroopAllocationStrategy.ProportionalDistribution:
                troopPlacementForNonTargetedCastles = this.AllocateTroopsToCastlesProportionally(
                    castleTargetingInfo.CastlesNotTargeted,
                    numTroopsToAllocateForNonTargetedCastles
                    );
                break;
            }
            var troopPlacementList = troopPlacementForTargetedCastles.ToList().Concat(troopPlacementForNonTargetedCastles.ToList());

            return(troopPlacementList.OrderBy(t => t.CastleNum).Select(t => t.NumTroops).ToList());
        }
Beispiel #2
0
        public List <List <int> > GenerateTroopPlacements(
            bool restrictToStrategiesTargetingMajorityOfPoints,
            int valueToAssignPerNonTargetedCastle,
            TroopAllocationStrategy allocationStrategyForTargetedCastles,
            TroopAllocationStrategy allocationStrategyForNonTargetedCastles)
        {
            var subsetsOfCastlesToTarget = this._castleTargeter.GetPossibleTargetingStrategies(this._numCastles, restrictToStrategiesTargetingMajorityOfPoints);

            var troopPlacements = new List <List <int> >();

            foreach (var castlesToTarget in subsetsOfCastlesToTarget)
            {
                var troopPlacement = this.GenerateSingleTroopPlacement(
                    castlesToTarget,
                    valueToAssignPerNonTargetedCastle,
                    allocationStrategyForTargetedCastles,
                    allocationStrategyForNonTargetedCastles);
                troopPlacements.Add(troopPlacement);
            }
            return(troopPlacements);
        }