Пример #1
0
        public void DoAction(Game game, Player self)
        {
            var ball = game.Ball;
            var goal = Field.EnemyGoal.Center;

            if (ball.Owner == self)
            {
                var closestToGoal = goal.GetClosest(game.Enemy);
                if (closestToGoal.GetDistanceTo(goal) > Field.EnemyGoal.Height)
                {
                    self.ActionShootGoal();
                    return;
                }

                var enemyToGoal = game.Enemy.Players
                    .Where(pl => pl.Position.X > self.Position.X - 40)
                    .Select(pl => new { pl, dist = pl.GetDistanceTo(self) })
                    .OrderBy(tp => tp.dist)
                    .FirstOrDefault();

                if (enemyToGoal != null && enemyToGoal.dist < 120)
                {
                    self.ActionShoot(game.GetSmartShoot(self));
                    return;
                }

                var closestEnemy = self.GetClosest(game.Enemy);
                if (self.GetDistanceTo(closestEnemy) < 50)
                {
                    self.ActionShoot(game.GetSmartShoot(self));
                    return;
                }

                var pos = self.GetCenterShootout(game.Enemy);
                if (self.Position.X < Field.Borders.Center.X * 0.75)
                {
                    self.ActionShoot(pos);
                    return;
                }

                self.ActionGo(pos);
                return;
            }

            if (Utility.TryField(game, self))
                return;

            self.ActionGo(Field.MyGoal.GetClosest(game.Enemy));
        }
Пример #2
0
        public void DoAction(Game game, Player self)
        {
            var ball = game.Ball;
            var closestEnemy = self.GetClosest(game.Enemy);

            if (ball.Owner == self)
            {
                var sweeper = game.My.Sweeper();

                if (sweeper.IsSafe(game, self))
                {
                    self.ActionShoot(sweeper, 50);
                }
                else
                {
                    var pos = self.GetCenterShootout(game.Enemy);
                    self.ActionShoot(pos);
                }

                return;
            }

            if (Utility.TryKeeper(game, self))
                return;

            //if (ball.GetDistanceTo(Field.MyGoal) > 800)
            //{
            //    self.ActionGo(new Vector(Field.MyGoal.Height/2, Field.MyGoal.Center.Y));
            //}
            //else
            //{
                //get ball target
                var distanceCoeff = ball.Velocity.Length;// / ball.GetDistanceTo(self);
                var target = ball.Position.Y + ball.Velocity.Y * distanceCoeff;

                var y = Math.Max(Math.Min(target, Field.MyGoal.Bottom.Y), Field.MyGoal.Top.Y);

                var lenCoeff = ball.GetDistanceTo(Field.MyGoal.Center) * 2 / Field.MyGoal.Height;
                var x = Math.Min(ball.Position.X/lenCoeff, Field.MyGoal.Height / 2);

                self.ActionGo(new Vector(x, y));
            //}
        }
Пример #3
0
        public void DoAction(Game game, Player self)
        {
            var ball = game.Ball;

            if (ball.Owner == self)
            {
                var sweeper = game.My.Sweeper();
                var defender = game.My.Defender();

                if (sweeper.IsSafe(game, self))
                {
                    self.ActionShoot(sweeper, self.GetDistanceTo(sweeper) * 1.5f);
                }
                else if (defender.IsSafe(game, self))
                {
                    self.ActionShoot(defender, self.GetDistanceTo(defender) * 1.5f);
                }
                else
                {
                    var pos = self.GetCenterShootout(game.Enemy);
                    self.ActionShoot(pos);
                }

                return;
            }

            if (Utility.TryKeeper(game, self))
                return;

            var ballPos = game.Ball.GetBallNextPosition();

            var ballToGoalVector = ballPos - Field.MyGoal.Center;
            var keeperVectorScale = Field.MyGoal.Height/2/ballToGoalVector.Length;
            var keeperToGoalVector = ballToGoalVector * keeperVectorScale;
            var keeperPosition = Field.MyGoal.Center + keeperToGoalVector;

            self.ActionGo(keeperPosition);
        }
Пример #4
0
        public void DoAction(Game game, Player self)
        {
            var ball = game.Ball;

            if (ball.Owner == self)
            {
                var defender = game.My.Defender();

                if (defender.IsSafe(game, self))
                {
                    self.ActionShoot(defender, self.GetDistanceTo(defender) * 1.5f);
                }
                else
                {
                    if (self.Position.X < Field.Borders.Center.X*0.2)
                    {
                        float yPos;
                        var center = Field.Borders.Center;
                        if (self.Position.Y > center.Y)
                        {
                            yPos = center.Y + center.Y/2;
                        }
                        else
                        {
                            yPos = center.Y - center.Y/2;
                        }

                        self.ActionShoot(new Vector(0, yPos));
                        return;
                    }


                    if (self.Position.X < Field.Borders.Center.X * 0.75)
                    {
                        var pos = self.GetCenterShootout(game.Enemy);
                        self.ActionShoot(pos);
                        return;
                    }

                    self.ActionShootGoal();
                    return;
                }

                return;
            }

            if (Utility.TryField(game, self))
                return;

            var closestToGoal = Field.MyGoal.GetClosest(game.Enemy);
            IPosition target;
            if (ball.GetBallNextPosition().GetDistanceTo(Field.MyGoal) > closestToGoal.GetDistanceTo(Field.MyGoal))
            {
                target = closestToGoal;
            }
            else
            {
                target = ball;
            }

            target = new Vector(target.Position.X*0.8, target.Position.Y);
            self.ActionGo(target);
        }