public RobotCommand DoStep(IList <Robot.Common.Robot> robots, int robotToMoveIndex, Map map)
        {
            MRobot robot = MRobot.getRobot(robotToMoveIndex);
            var    task  = robot.getTask();

            return(task.proccess(robots, robot, map));
        }
Пример #2
0
        public override RobotCommand proccess(IList <Robot.Common.Robot> robots, MRobot robot, Map map)
        {
            var pos        = robots[robot.id].Position;
            int hasEnergy  = robots[robot.id].Energy - 300;
            int needEnergy = Util.EnergyToPosition(position, pos);

            if (needEnergy < hasEnergy)
            {
                return(new MoveCommand {
                    NewPosition = position
                });
            }
            else
            {
                int m      = (int)Math.Ceiling(1.0 * needEnergy / hasEnergy);
                int deltaX = pos.X - position.X;
                int deltaY = pos.Y - position.Y;
                for (int i = 0; i < m; i++)
                {
                    robot.addTask(new MoveTask()
                    {
                        position = new Position(pos.X + deltaX * i, pos.Y + deltaY * i)
                    });
                }
                return(robot.getTask().proccess(robots, robot, map));
            }
        }