public static Moves CalculatePreventBonusTask(BotMain state, BotBonus bonusToPrevent, PlayerIDType opponentID, int maxDeployment, BotTerritory.DeploymentType conservativeLevel)
        {
            var territoriesToPrevent = bonusToPrevent.GetOwnedTerritories();

            var opponentAttacks = PreventTerritoriesTask.CalculateGuessedOpponentTakeOverMoves(state, territoriesToPrevent, opponentID, true, conservativeLevel);

            if (opponentAttacks == null)
            {
                return(new Moves());
            }

            var preventTerritoryMovesByDeploying = PreventTerritoriesTask.CalculatePreventTerritoriesTask(state, territoriesToPrevent, opponentID, maxDeployment, conservativeLevel);
            var visibleOpponentTerritories       = bonusToPrevent.GetVisibleOpponentTerritories();
            var breakBestTerritoryMoves          = NoPlanBreakBestTerritoryTask.CalculateNoPlanBreakBestTerritoryTask(state, maxDeployment, visibleOpponentTerritories, state.VisibleMap, state.WorkingMap, "PreventBonusTask");

            if (breakBestTerritoryMoves == null)
            {
                return(preventTerritoryMovesByDeploying);
            }
            else if (breakBestTerritoryMoves.GetTotalDeployment() <= preventTerritoryMovesByDeploying.GetTotalDeployment())
            {
                return(breakBestTerritoryMoves);
            }
            else
            {
                return(preventTerritoryMovesByDeploying);
            }
        }
        private void CalculatePreventValue(BotBonus bonus, BotMap mapToWriteIn)
        {
            var ownedTerritories = bonus.GetOwnedTerritories();
            var ownArmies        = 0;

            foreach (var ownedTerritory in ownedTerritories)
            {
                ownArmies += ownedTerritory.Armies.DefensePower;
            }

            GamePlayer maxOpponent     = null;
            int        maxPreventValue = int.MinValue;

            foreach (var opponent in BotState.Opponents)
            {
                var val = CalculatePreventValue(bonus, ownedTerritories, opponent, ownArmies);
                if (val > maxPreventValue)
                {
                    maxPreventValue = val;
                    maxOpponent     = opponent;
                }
            }

            if (maxOpponent != null)
            {
                var b = mapToWriteIn.Bonuses[bonus.ID];
                b.PreventTakeOverValue    = maxPreventValue;
                b.PreventTakeOverOpponent = maxOpponent.ID;
            }
        }