예제 #1
0
 public override void Initialize(Competitions competitions)
 {
     base.Initialize(competitions);
     Map          = Competitions.GetSensorsData <PositionSensorsData>(ControlledRobot).BuildMap();
     RobotLocator = new RobotLocator(Map);
     enumerator   = currentCommands.GetEnumerator();
 }
예제 #2
0
파일: Azura.cs 프로젝트: air-labs/CVARC
        private IEnumerable <Command> RepairStarship()
        {
            var nearSocket = Map.Walls.Where(x => x.Type.ToLower().Contains(color)).OrderBy(GetDistance).FirstOrDefault();

            if (nearSocket == null)
            {
                return(new Command[0]);
            }
            var path = PathSearcher.FindPath(Map, OurCoordinates, nearSocket.DiscreteCoordinate);

            if (path.Length == 0)
            {
                if (Map.CurrentPosition.X - nearSocket.AbsoluteCoordinate.X > Epsilon)
                {
                    return(RobotLocator.GetCommandsByDirection(Direction.Left));
                }
                if (Map.CurrentPosition.X - nearSocket.AbsoluteCoordinate.X < -Epsilon)
                {
                    return(RobotLocator.GetCommandsByDirection(Direction.Right));
                }
                if (Map.CurrentPosition.Y - nearSocket.AbsoluteCoordinate.Y > Epsilon)
                {
                    return(RobotLocator.GetCommandsByDirection(Direction.Down));
                }
                if (Map.CurrentPosition.Y - nearSocket.AbsoluteCoordinate.Y < -Epsilon)
                {
                    return(RobotLocator.GetCommandsByDirection(Direction.Up));
                }
                hasDetail = false;
                return(new[] { Command.Act(CommandAction.Release) });
            }
            return(RobotLocator.GetCommandsByDirection(path.First()));
        }
예제 #3
0
파일: MolagBal.cs 프로젝트: air-labs/CVARC
        protected override IEnumerable <Command> FindNextCommands()
        {
            var path     = PathSearcher.FindPath(Map, OurCoordinates, OpponentCoordinates);
            var commands = path.Length == 0 ? GoBack() : RobotLocator.GetCommandsByDirection(path.First());

            lastCommand = path.FirstOrDefault();
            return(commands);
        }
예제 #4
0
파일: Sanguine.cs 프로젝트: air-labs/CVARC
 protected override IEnumerable <Command> FindNextCommands()
 {
     while (currentCommand >= currentPath.Length)
     {
         var x = random.Next(1, 7);
         var y = random.Next(1, 5);
         currentPath    = PathSearcher.FindPath(Map, OurCoordinates, new Point(x, y));
         currentCommand = 0;
     }
     return(RobotLocator.GetCommandsByDirection(currentPath[currentCommand++]));
 }
예제 #5
0
파일: Azura.cs 프로젝트: air-labs/CVARC
        private IEnumerable <Command> GripDetail()
        {
            var nearDetail = Map.Details.OrderBy(GetDistance).FirstOrDefault();

            if (nearDetail == null)
            {
                return(new Command[0]);
            }
            color = nearDetail.Type.Split(new[] { "Detail" }, StringSplitOptions.None).First().ToLower();
            var path = PathSearcher.FindPath(Map, OurCoordinates, nearDetail.DiscreteCoordinate);

            hasDetail = path.Length == 0;
            return(hasDetail ? new[] { Command.Act(CommandAction.Grip) } : RobotLocator.GetCommandsByDirection(path.First()));
        }
예제 #6
0
        private static void Main(string[] args)
        {
            var server       = new CvarcClient(args, Settings).GetServer <PositionSensorsData>();
            var sensorData   = server.Run().SensorsData;
            var map          = sensorData.BuildMap();
            var robotLocator = new RobotLocator(map);
            var path         = PathSearcher.FindPath(map, map.GetDiscretePosition(map.CurrentPosition), new Point(2, 1));//(2, 1) - just random point

            foreach (var direction in path)
            {
                foreach (var command in robotLocator.GetCommandsByDirection(direction))
                {
                    sensorData = server.SendCommand(command);
                    robotLocator.Update(sensorData);
                }
            }
            server.SendCommand(new Command {
                Action = CommandAction.WaitForExit
            });
        }
예제 #7
0
파일: MolagBal.cs 프로젝트: air-labs/CVARC
 private IEnumerable <Command> GoBack()
 {
     return(RobotLocator.GetCommandsByDirection(lastCommand.Invert()).Concat(new[] { Command.Sleep(3) }));
 }
예제 #8
0
        protected override IEnumerable <Command> FindNextCommands()
        {
            var path = PathSearcher.FindPath(Map, OurCoordinates, OpponentCoordinates);

            return(path.Length == 0 || path.Length == 1 ? new Command[0] : RobotLocator.GetCommandsByDirection(path.First()));
        }