예제 #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*0.7)
                {
                    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;
                }

                self.ActionGo(goal);
                return;
            }

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

            var centerX = goal.X*0.8;

            IPosition target;
            if (ball.Position.X > goal.X * 0.6)
            {
                var targetX = Math.Max(centerX, ball.Position.X * 0.95);
                var mul = ball.Position.Y < goal.Y ? 1 : -1;
                var targetY = goal.Y + Field.EnemyGoal.Height * 0.6 * mul;

                target = new Vector(targetX, targetY);
            }
            else
            {
                target = new Vector(centerX, goal.Y);
            }


            self.ActionGo(target);
        }
예제 #2
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);
        }
예제 #3
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));
        }
예제 #4
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 * 0.8)
                {
                    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;
                }

                self.ActionGo(Field.EnemyGoal.Bottom);
                return;
            }

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

            IPosition target;
            if (game.InAttack)
            {
                if (ball.Position.X > goal.X * 0.6)
                {
                    var centerX = goal.X * 0.82;
                    var targetX = Math.Max(centerX, ball.Position.X * 0.95);
                    var targetY = goal.Y - Field.EnemyGoal.Height * 0.75;

                    target = new Vector(targetX, targetY);
                }
                else
                {
                    target = new Vector(Field.Borders.Bottom.X, Field.MyGoal.Height * 0.7);
                }
            }
            else
            {
                var closestUpperPlayers = game.Enemy.Players
                    .Where(pl => pl.Position.Y < Field.Borders.Center.Y)
                    .Select(pl => new {pl, dist = pl.GetDistanceTo(Field.MyGoal.Top)})
                    .OrderBy(tp => tp.dist);

                if (closestUpperPlayers.Count() > 1)
                {
                    target = closestUpperPlayers.Skip(1).First().pl;
                }
                else
                {
                    target = new Vector(Field.Borders.Top.X, Field.MyGoal.Height * 0.7);
                }
            }

            self.ActionGo(target);
        }
예제 #5
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);
        }