Пример #1
0
        //More pricey chicken.
        static string GetOutputMPC(PlayField playField, Bomb bomb = null)
        {
            //Decide whether to attack with bomb or not and record to output stringbuilder.
            if (bomb != null)
            {
                playField.AttackWithBomb(bomb.X, bomb.Y, bomb.Radius);
                //algoOutput.AppendLine(String.Format("bomb {0} {1} {2}", bomb.Radius, bomb.X, bomb.Y));
            }

            //Evaluate for pigs.
            playField.EvaluatePlayFieldForPigsMPC();

            //Find highest score and attack with pigs and record to output stringbuilder.
            Point bestPigAttackPoint;
            int pigsNeededForDetonation;

            while (playField.GoldAvailableForAttack >= GameRules.PigPrice && playField.ResultScore < playField.GoldSpentForDefense)
            {
                bestPigAttackPoint = playField.GetMostEffectivePigPoint();
                pigsNeededForDetonation = playField.GetPigsNeededForDetonation(bestPigAttackPoint.X, bestPigAttackPoint.Y);
                playField.AttackWithPigsAndEvaluateMPC(bestPigAttackPoint.X, bestPigAttackPoint.Y, pigsNeededForDetonation);
                //algoOutput.AppendLine(String.Format("pigs {0} {1} {2}", pigsNeededForDetonation, bestPigAttackPoint.X, bestPigAttackPoint.Y));
            }

            //Return output stringbuilder variable.
            return playField.PerformedActions.ToString().TrimEnd();
        }
Пример #2
0
        public Bomb GetMostEffectiveBombRelative()
        {
            double score;
            double maxScore = -1;
            int x = 0;
            int y = 0;
            int radius = 0;
            Bomb bomb;

            for (int r = MaxBombRadius; r >= 0; r--)
            {
                for (int i = 0; i < PlayFieldSize; i++)
                {
                    for (int j = 0; j < PlayFieldSize; j++)
                    {
                        //Score = lost units in gold^(1 + lost units in gold / total units in gold) / gold needed for bomb.
                        score = Math.Pow(playFieldBombsScores[i, j, r], (1 + playFieldBombsScores[i, j, r] / (double)this.GoldSpentForDefense)) / (double)((r + 1) * GameRules.BombPricePerRadius);

                        if (maxScore < score)
                        {
                            maxScore = score;
                            x = j;
                            y = (PlayFieldSize - 1) - i;
                            radius = r;
                        }
                    }
                }
            }

            bomb = new Bomb(x, y, radius);

            return bomb;
        }
Пример #3
0
        public Bomb GetMostEffectiveBombGreedy()
        {
            float score;
            float maxScore = -1;
            int x = 0;
            int y = 0;
            int radius = 0;
            Bomb bomb;

            for (int r = MaxBombRadius; r >= 0; r--)
            {
                for (int i = 0; i < PlayFieldSize; i++)
                {
                    for (int j = 0; j < PlayFieldSize; j++)
                    {
                        //Score = lost units in gold / gold needed for bomb.
                        score = playFieldBombsScores[i, j, r] / (float)((r + 1) * GameRules.BombPricePerRadius);

                        if (maxScore < score)
                        {
                            maxScore = score;
                            x = j;
                            y = (PlayFieldSize - 1) - i;
                            radius = r;
                        }
                    }
                }
            }

            bomb = new Bomb(x, y, radius);

            return bomb;
        }