示例#1
0
 public bool DoTurn(PirateShip ship)
 {
     if (ship.Distance(camp) > sensitivity)
     {
         return(ship.Sail(camp));
     }
     return(false);
 }
示例#2
0
        public bool DoTurn(Squad squad)
        {
            if (squad.HasCapsule)
            {
                PirateShip CapsuleHolder     = squad.First(x => x.HasCapsule);
                Mothership ClosestMothership = Bot.Engine.MyMotherships.Nearest(CapsuleHolder);
                Squad      Boosters          = squad.Filter(x => x.UniqueId != CapsuleHolder.UniqueId && x.PushReloadTurns <= 0 && (true || x.Distance(ClosestMothership) - CapsuleHolder.Distance(ClosestMothership) < x.PushRange))
                                               .OrderBy(x => x.Distance(CapsuleHolder)).Take(System.Math.Max(MaxPushes, CapsuleHolder.NumberOfPushesForCapsuleLoss - 1)).ToList();
                int  BoostingDistance = Bot.Engine.GetDistanceAgainst(Boosters, CapsuleHolder);
                bool ShouldPush;
                {
                    Squad        EnemyPirates = Bot.Engine.EnemyLivingPirates.Filter(x => x.Distance(CapsuleHolder) <= x.PushRange + x.MaxSpeed);
                    PirateShip[] Campers;
                    Bot.Engine.CheckForCamper(CampDuration, out Campers);
                    bool ExistsDeeperCamp = Campers.Any(x =>
                    {
                        bool IsFurther              = !EnemyPirates.ContainsPirate(x);
                        bool IsCloserToMothership   = EnemyPirates.All(y => x.Distance(ClosestMothership) < y.Distance(ClosestMothership));
                        Squad LocalBunk             = Bot.Engine.EnemyLivingPirates.Filter(y => y.Distance(CapsuleHolder) <= y.PushRange + y.MaxSpeed && Bot.Engine.GetCampLength(y) >= CampDuration);
                        bool MeetsBunkerRequirement = IsBunker(LocalBunk, LocalBunk.Middle, CapsuleHolder.NumberOfPushesForCapsuleLoss);

                        return(IsFurther && IsCloserToMothership && MeetsBunkerRequirement);
                    });

                    bool IsSafeAfterBoost;
                    {
                        Location NewLocation = (Location)(((Point)CapsuleHolder).InDirection(ClosestMothership, BoostingDistance + CapsuleHolder.MaxSpeed));
                        Squad    LocalBunk   = Bot.Engine.EnemyLivingPirates.Filter(y => y.Distance(CapsuleHolder) <= y.PushRange + y.MaxSpeed && Bot.Engine.GetCampLength(y) >= CampDuration);
                        IsSafeAfterBoost = !IsBunker(LocalBunk, NewLocation, CapsuleHolder.NumberOfPushesForCapsuleLoss);
                    }

                    ShouldPush = CapsuleHolder.Distance(ClosestMothership) <= ClosestMothership.UnloadRange + CapsuleHolder.MaxSpeed + BoostingDistance - 1 ||
                                 (IsBunker(EnemyPirates, CapsuleHolder) && ((!ExistsDeeperCamp && IsSafeAfterBoost) || IgnoreDeeperCamps));
                }

                if (ShouldPush)
                {
                    Boosters = Boosters.Where(x => x.CanPush(CapsuleHolder)).ToList();
                    Boosters.ForEach(x => x.Push(CapsuleHolder, ClosestMothership));
                    CapsuleHolder.Sail(ClosestMothership);
                }
                else
                {
                    CapsuleHolder.Sail(ClosestMothership, x =>
                    {
                        if (x is Pirate pirate)
                        {
                            return(IsBunker(x, CapsuleHolder.NumberOfPushesForCapsuleLoss) ? AvoidingDistance : 0);
                        }
                        return(0);
                    }, true);
                    foreach (PirateShip p in Boosters)
                    {
                        p.Sail(CapsuleHolder.ExpectedLocation);
                    }
                }
                foreach (PirateShip p in squad.FilterOutBySquad(Boosters.AddPirates(CapsuleHolder)))
                {
                    p.Sail(capsule.InitialLocation);
                }
                return(true);
            }
            else if (capsule.IsAlive())
            {
                foreach (PirateShip p in squad)
                {
                    p.Sail(capsule, EnableWarps: true);
                }
                return(true);
            }
            else
            {
                foreach (PirateShip p in squad)
                {
                    p.Sail(capsule.InitialLocation, EnableWarps: true);
                }
                return(true);
            }
            return(false);
        }