Esempio n. 1
0
        /// <summary>
        /// Атака
        /// </summary>
        /// <param name="moveRate"></param>
        protected override void Atack(MoveRate moveRate)
        {
            var enemiesOnPosition = EnemiesOnPosition(moveRate.Move.To.Position);
            var coinsTo           = GoldOnPosition(moveRate.Move.To.Position);
            var coinsFrom         = GoldOnPosition(moveRate.Move.From.Position);

            if (enemiesOnPosition == 0)             // || (coinsTo == 0 && coinsFrom == 0))
            {
                return;
            }

            //Если стоим с золотом прямо у корабля - не атакуем если у врага нет золота
            //if (coinsFrom > 0 && coinsTo == 0 && Distance(MyShip.Position, moveRate.Move.Pirate.Position) == 1)
            //	return;

            //Если кто-то другой без золота может атаковать этого же чудика, а я с золотом - не бьем
            var myEmptyFriendAtackers = MyPirates.Count(p => p.Position.Position != moveRate.Move.From.Position &&
                                                        GoldOnPosition(p.Position.Position) == 0 &&
                                                        Distance(p.Position.Position, moveRate.Move.To.Position) <= 1);

            if (myEmptyFriendAtackers > 0 && coinsFrom > 0)
            {
                return;
            }

            //Не атаковать если враг в 2-х ходах от его корабля
            var occupationTeamId = Board.Map[moveRate.Move.To.X, moveRate.Move.To.Y].OccupationTeamId;

            if (occupationTeamId.HasValue && Distance(Board.Teams[occupationTeamId.Value].Ship.Position, moveRate.Move.To.Position) < 3)
            {
                return;
            }

            double atackBackCoef = 1;

            //Не атаковать назад если можно идти к кораблю с золотом. Вот так не работает оборона
            //if (coinsFrom > 0 && Distance(moveRate.Move.From, MyShip.Position) < Distance(moveRate.Move.To, MyShip.Position))
            //	atackBackCoef = 0.4;

            moveRate.AddRate("Atack", (Coef.Atack + ((enemiesOnPosition - 1) * Coef.AtackManyEnemies)) * (1 + coinsFrom * 0.1) * (1 + coinsTo * 0.1) * atackBackCoef);
        }
Esempio n. 2
0
        /// <summary>
        /// перемещаем золото ближе к кораблю
        /// </summary>
        /// <param name="moveRate"></param>
        protected override void MoveShipToMyPirateWithGold(MoveRate moveRate)
        {
            if (!IsShipMove(moveRate.Move))
            {
                return;
            }

            var myPiratesWithGold = MyPirates.Where(p => GoldOnPosition(p.Position.Position) > 0 && Distance(moveRate.Move.From.Position, p.Position.Position) > Distance(moveRate.Move.To.Position, p.Position.Position)).ToList();

            if (!myPiratesWithGold.Any())
            {
                return;
            }

            var coins = myPiratesWithGold.Sum(p => GoldOnPosition(p.Position.Position));

            moveRate.AddRate("MoveShipToPirateWithGold", Coef.MoveToShipWithGold
                             * (myPiratesWithGold.Count > 1 ? (1 + myPiratesWithGold.Count * 0.1) : 1)
                             * (coins > 1 ? (1 + coins * 0.1) : 1)
                             );
        }
Esempio n. 3
0
        /// <summary>
        /// Ход под удар
        /// </summary>
        /// <param name="moveRate"></param>
        protected override void MoveUnderAtack(MoveRate moveRate)
        {
            //Не боимся слазить с корабля стоя на нем
            if (moveRate.Move.From.Position == MyShip.Position)
            {
                return;
            }

            var myAtakers = AllEnemies.Count(p => Distance(p.Position.Position, moveRate.Move.To.Position) == 1);

            if (myAtakers == 0)
            {
                return;
            }

            var myDefence = MyPirates.Count(p => Distance(p.Position.Position, moveRate.Move.To.Position) == 1) - 1;

            if (myDefence < myAtakers)
            {
                moveRate.AddApplyToAllRate("MoveUnderAtack", Coef.MoveUnderAtack);
            }
        }