Example #1
0
 public int GetTicksToUpN(AHock ho, Point to, double takePuck = -1, int limit = 500)
 {
     var result = 0;
     for (; result < limit && (takePuck < 0 ? !CanStrike(ho, to) : ho.GetDistanceTo2(to) > takePuck*takePuck); result++)
     {
         ho.MoveTo(to);
     }
     return result;
 }
Example #2
0
        public Point FindWayPoint(Hockeyist self)
        {
            var okDist = 5 * HoRadius;

            var   bestTime = Inf;
            Point sel      = null;
            //TimerStart();
            var bot = Hockeyists.Count(x => !x.IsTeammate && IsInGame(x) && x.Y > RinkCenter.Y);
            var top = Hockeyists.Count(x => !x.IsTeammate && IsInGame(x) && x.Y <= RinkCenter.Y);

            foreach (Point p in WayPoints.ToArray().OrderBy(x => ((Point)x).GetDistanceTo(self)).Take(10))
            {
                var I = new AHock(self);
                if (p.GetDistanceTo2(I) <= okDist * okDist || MyRight() && I.X < p.X || MyLeft() && I.X > p.X)
                {
                    continue;
                }

                var cands = Hockeyists
                            .Where(x => !x.IsTeammate && IsInGame(x))
                            .Select(x => new AHock(x)).ToArray();

                var time = 0;
                var ok   = true;
                while (p.GetDistanceTo2(I) > okDist * okDist && ok)
                {
                    I.MoveTo(p);
                    foreach (var c in cands)
                    {
                        c.MoveTo(I);
                        if (CanStrike(c, I.PuckPos()) || // достанет шайбу
                            CanStrike(c, I) || // достанет меня
                            I.GetDistanceTo2(c) <= 2 * HoRadius * 2 * HoRadius // столкнется со мной
                            )
                        {
                            ok = false;
                            break;
                        }
                    }
                    time++;
                }
                if (ok)
                {
                    if (p.Y > RinkCenter.Y && bot > top || p.Y <= RinkCenter.Y && top > bot)
                    {
                        time *= 3;
                    }
                    if (time < bestTime)
                    {
                        bestTime = time;
                        sel      = p.Clone();
                    }
                }
            }
            //Log("FindWayPoint " + TimerStop());
            return(sel);
        }
Example #3
0
        public int GetTicksToUpN(AHock ho, Point to, double takePuck = -1, int limit = 500)
        {
            var result = 0;

            for (; result < limit && (takePuck <0 ? !CanStrike(ho, to) : ho.GetDistanceTo2(to)> takePuck * takePuck); result++)
            {
                ho.MoveTo(to);
            }
            return(result);
        }
Example #4
0
 public int GetTicksToDownN(AHock ho, Point to, double takePuck = -1, int limit = 300)
 {
     var result = 0;
     for (; result < limit && (takePuck < 0 ? !CanStrike(ho, to) : ho.GetDistanceTo2(to) > takePuck * takePuck); result++)
     {
         var turn = RevAngle(ho.GetAngleTo(to));
         var speedUp = -GetSpeedTo(turn);
         ho.Move(speedUp, TurnNorm(turn, ho.AAgility));
     }
     return result >= limit ? Inf : result;
 }
Example #5
0
        public int GetTicksToDownN(AHock ho, Point to, double takePuck = -1, int limit = 300)
        {
            var result = 0;

            for (; result < limit && (takePuck <0 ? !CanStrike(ho, to) : ho.GetDistanceTo2(to)> takePuck * takePuck); result++)
            {
                var turn    = RevAngle(ho.GetAngleTo(to));
                var speedUp = -GetSpeedTo(turn);
                ho.Move(speedUp, TurnNorm(turn, ho.AAgility));
            }
            return(result >= limit ? Inf : result);
        }
Example #6
0
        public Point FindWayPoint(Hockeyist self)
        {
            var okDist = 5*HoRadius;

            var bestTime = Inf;
            Point sel = null;
            //TimerStart();
            var bot = Hockeyists.Count(x => !x.IsTeammate && IsInGame(x) && x.Y > RinkCenter.Y);
            var top = Hockeyists.Count(x => !x.IsTeammate && IsInGame(x) && x.Y <= RinkCenter.Y);

            foreach (Point p in WayPoints.ToArray().OrderBy(x => ((Point) x).GetDistanceTo(self)).Take(10))
            {
                var I = new AHock(self);
                if (p.GetDistanceTo2(I) <= okDist*okDist || MyRight() && I.X < p.X || MyLeft() && I.X > p.X)
                    continue;

                var cands = Hockeyists
                    .Where(x => !x.IsTeammate && IsInGame(x))
                    .Select(x => new AHock(x)).ToArray();

                var time = 0;
                var ok = true;
                while (p.GetDistanceTo2(I) > okDist*okDist && ok)
                {
                    I.MoveTo(p);
                    foreach (var c in cands)
                    {
                        c.MoveTo(I);
                        if (CanStrike(c, I.PuckPos()) // достанет шайбу
                            || CanStrike(c, I) // достанет меня
                            || I.GetDistanceTo2(c) <= 2*HoRadius*2*HoRadius // столкнется со мной
                            )
                        {
                            ok = false;
                            break;
                        }
                    }
                    time++;
                }
                if (ok)
                {
                    if (p.Y > RinkCenter.Y && bot > top || p.Y <= RinkCenter.Y && top > bot)
                        time *= 3;
                    if (time < bestTime)
                    {
                        bestTime = time;
                        sel = p.Clone();
                    }
                }
            }
            //Log("FindWayPoint " + TimerStop());
            return sel;
        }
Example #7
0
 public static bool CanStrike(AHock hock, Point to)
 {
     return(Math.Abs(hock.GetAngleTo(to)) <= Game.StickSector / 2 &&
            hock.GetDistanceTo2(to) <= Game.StickLength * Game.StickLength &&
            hock.KnockDown == 0 && hock.CoolDown == 0);
 }