public bool DoTurn(PirateShip ship)
 {
     Delegates.ScoringFunction <SpaceObject> scorer = x =>
                                                      x.UniqueId == ship.UniqueId ? selfBombingScorer((PirateShip)((Pirate)x)) : bombingScorer(x);
     if (ship.StickyBombs.Length > 0)
     {
         /*
          * int remaining = ship.StickyBombs.Select(x => x.Countdown + 1).Min();
          * ship.Sail(MaximalScore(ship, ship.MaxSpeed * remaining).arg0);
          */
         Location direction = Bot.Engine.MyLivingPirates.Where(x => x.StickyBombs.Length <= 0).Select(x => x.Location.Subtract(ship.Location).Multiply(-1)).Concat(
             Bot.Engine.EnemyLivingPirates.Where(x => x.StickyBombs.Length <= 0).Select(x => x.Location.Subtract(ship.Location))).Middle();
         ship.Sail(ship.Location.Add(direction));
         return(true);
     }
     else
     {
         SpaceObject[] bombable = Bot.Engine.PushableSpaceObjects.Concat(new SpaceObject[] { ship })
                                  .Where(x => ship.CanStickBomb(x)).ToArray();
         SpaceObject max = bombable.FirstBy(x => - scorer(x));
         if (scorer(max) > 0 && Bot.Engine.CanStickBomb)
         {
             ship.StickBomb(max);
             return(true);
         }
         return(false);
     }
 }
Exemple #2
0
        public bool DoTurn(PirateShip ship)
        {
            // Check if halt is needed
            Asteroid[] AsteroidsInRange = Bot.Engine.AllLivingAsteroids.Where(x => Bot.Engine.GetHits(x) == 0 && Filter(x) && x.Distance(ship) - x.Size < (ship.MaxSpeed + x.EffectiveSpeed()) * DangerRange).ToArray();
            if (ship.PushReloadTurns > 0 || AsteroidsInRange.IsEmpty())
            {
                return(false);
            }
            Asteroid NearestAsteroid = AsteroidsInRange.Nearest(ship);

            if (ship.CanPush(NearestAsteroid))
            {
                return(ship.Push(NearestAsteroid, PushLocator(NearestAsteroid, ship)));
            }
            else if (!NearestAsteroid.IsHalted())
            {
                int EffectiveDistance = NearestAsteroid.Distance(ship) - NearestAsteroid.Size;
                if (EffectiveDistance < HaltingRange * (ship.MaxSpeed + NearestAsteroid.EffectiveSpeed()))
                {
                    if (EffectiveDistance < HaltingRange * NearestAsteroid.EffectiveSpeed())
                    {
                        return(ship.Sail(NearestAsteroid.Add(NearestAsteroid.Direction.Normalized().Multiply(NearestAsteroid.EffectiveSpeed() + ship.PushRange))));
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Exemple #3
0
 public bool DoTurn(PirateShip ship)
 {
     if (ship.Distance(camp) > sensitivity)
     {
         return(ship.Sail(camp));
     }
     return(false);
 }
Exemple #4
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);
        }
 public bool DoTurn(PirateShip ship)
 {
     if (Bot.Engine.Enemy.BotName == "25772")
     {
         if (Bot.Engine.MyCapsules[0].IsAlive() && Bot.Engine.MyCapsules[0].IsHeld() && ship.InPushRange(Bot.Engine.MyLivingCapsules[0]) && ship.IsHeavy)
         {
             ship.Push(Bot.Engine.MyLivingCapsules[0].Holder, Bot.Engine.MyMotherships[0]);
         }
         else if (ship.IsNormal)
         {
             ship.Sail(Bot.Engine.MyMotherships[0]);
         }
         return(true);
     }
     else if (Bot.Engine.Enemy.BotName == "25766")
     {
         PirateShip p       = ship;
         Capsule    capsule = Bot.Engine.MyCapsules[0];
         if (p.Id == 0)
         {
             PirateShip other = Bot.Engine.GetMyPirateById(1);
             Location   dest  = Bot.Engine.Self.Score >= 3 ? new Location(3797, 4358) : new Location(2534, 3936);
             if (!p.Sail(dest) && p.InPushRange(other))
             {
                 p.Push(other, capsule);
             }
         }
         else
         {
             PirateShip other  = Bot.Engine.GetMyPirateById(0);
             bool       IsHeld = capsule.IsAlive() && capsule.IsHeld();
             if (p.IsNormal)
             {
                 if (IsHeld)
                 {
                     ((Pirate)p).SwapStates(other);
                 }
                 else
                 {
                     p.Sail(capsule);
                 }
             }
             else
             {
                 if (IsHeld)
                 {
                     p.Sail(Bot.Engine.MyMotherships[0]);
                 }
                 else
                 {
                     ((Pirate)p).SwapStates(other);
                 }
             }
         }
         return(true);
     }
     else if (Bot.Engine.Enemy.BotName == "26069")
     {
         int id = ship.Id;
         if (id == 0 || id == 2)
         {
             bool     Sailed = ship.Sail(id == 0 ? new Location(3646, 2200) : new Location(3646, 4000));
             Location target = id == 0 ? new Location(4700, 1200) : new Location(4700, 5200);
             if (!Sailed && Bot.Engine.GetEnemyPiratesInRange(target, 500).Count >= 2)
             {
                 Asteroid a = Bot.Engine.AllAsteroids[id / 2];
                 ship.Push(a, target.Add(new Location(225, 0)));
             }
         }
         else
         {
             Squad s = Bot.Engine.GetEnemyPiratesInRange(ship, Bot.Engine.Game.StickBombRange);
             if (s.Count > 0)
             {
                 ((Pirate)ship).StickBomb(s.First());
             }
         }
         return(true);
     }
     return(false);
 }