示例#1
0
        public void CalculateMoves()
        {
            CalculatedMoves = new Moves();
            var movesSoFar = new Moves();

            PlayCardsTask.PlayCards(BotState, movesSoFar);

            AILog.Log("Starting armies: " + BotState.MyIncome.Total);
            CalculateXBonusMoves(movesSoFar, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Normal);
            AILog.Log("Armies used after calculateXBonusMoves type 1: " + movesSoFar.GetTotalDeployment());
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            CalculateXBonusMoves(movesSoFar, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Conservative);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            CalculateXBonusMoves(movesSoFar, BotTerritory.DeploymentType.Conservative, BotTerritory.DeploymentType.Conservative);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            AILog.Log("Armies used after calculateXBonusMoves type 2: " + movesSoFar.GetTotalDeployment());
            CalculateSnipeBonusMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            AILog.Log("Armies used after calculateSnipeBonusMoves: " + movesSoFar.GetTotalDeployment());
            CalculateXBonusMoves(movesSoFar, 0, BotTerritory.DeploymentType.Normal);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);

            BotState.ExpansionTask.CalculateExpansionMoves(movesSoFar);


            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            AILog.Log("Armies used after calculateExpansionMoves: " + movesSoFar.GetTotalDeployment());
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);
            CalculateNoPlanBreakDefendMoves(movesSoFar, false, false, true, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Normal);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            AILog.Log("Armies used after calculateNoPlanBreakDefendMoves1: " + movesSoFar.GetTotalDeployment());
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);
            CalculateNoPlanBreakDefendMoves(movesSoFar, false, true, false, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Normal);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            AILog.Log("Armies used after calculateNoPlanBreakDefendMoves: " + movesSoFar.GetTotalDeployment());
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);
            CalculateNoPlanBreakDefendMoves(movesSoFar, false, false, true, BotTerritory.DeploymentType.Conservative, BotTerritory.DeploymentType.Conservative);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);
            CalculateNoPlanBreakDefendMoves(movesSoFar, false, true, true, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Conservative);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);
            CalculateFlankBonusMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            AILog.Log("Armies used after calculateFlankBonusMoves: " + movesSoFar.GetTotalDeployment());
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);
            CalculateNoPlanBreakDefendMoves(movesSoFar, true, false, false, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Normal);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.WorkingMap);
            CalculateNoPlanBreakDefendMoves(movesSoFar, true, false, false, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Conservative);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.VisibleMap);
            CalculateNoPlanAttackTerritoriesMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            AILog.Log("Armies used after calculateNoPlanAttackTerritoriesMoves2: " + movesSoFar.GetTotalDeployment());
            BotState.TerritoryValueCalculator.CalculateTerritoryValues(BotState.VisibleMap, BotState.VisibleMap);
            CalculateMoveIdleArmiesMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            CalculateJoinInAttacksMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            var supportTransferMoves = TransferMovesChooser.CalculateJoinStackMoves(BotState);

            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            MovesCommitter.CommittMoves(BotState, supportTransferMoves);
            movesSoFar.MergeMoves(supportTransferMoves);

            CalculateNoPlanCleanupMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            CalculateMoveIdleArmiesMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            CalculateJoinInAttacksMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);
            CalculateNoPlanTryoutAttackMoves(movesSoFar);
            BotState.DeleteBadMovesTask.CalculateDeleteBadMovesTask(movesSoFar);

            AILog.Log("Armies used after all moves done: " + movesSoFar.GetTotalDeployment());
            BotState.MapUpdater.UpdateMap(BotState.WorkingMap);
            DistanceCalculator.CalculateDistanceToBorder(BotState, BotState.VisibleMap, BotState.WorkingMap);
            BotState.ExpansionMapUpdater.UpdateExpansionMap();
            DistanceCalculator.CalculateDistanceToUnimportantTerritories(BotState.ExpansionMap, BotState.VisibleMap);
            DistanceCalculator.CalculateDistanceToImportantExpansionTerritories(BotState.ExpansionMap, BotState.VisibleMap);
            DistanceCalculator.CalculateDistanceToOpponentBorderCare3(BotState.ExpansionMap, BotState.VisibleMap);
            foreach (BotBonus emBonus in BotState.ExpansionMap.Bonuses.Values)
            {
                emBonus.ExpansionValue = BotState.VisibleMap.Bonuses[emBonus.ID].ExpansionValue;
            }
            DistanceCalculator.CalculateDistanceToHighlyImportantExpansionTerritories(BotState.ExpansionMap, BotState.VisibleMap);
            DistanceCalculator.CalculateDistanceToOpponentBorderCare4(BotState.ExpansionMap, BotState.VisibleMap);
            var transferMoves = TransferMovesChooser.CalculateTransferMoves2(BotState);

            MovesCommitter.CommittMoves(BotState, transferMoves);
            movesSoFar.MergeMoves(transferMoves);
            CalculateDelayMoves(movesSoFar);
            MovesCleaner.CleanupMoves(BotState, movesSoFar);
            movesSoFar      = BotState.MovesScheduler2.ScheduleMoves(movesSoFar);
            CalculatedMoves = movesSoFar;
        }