internal static CoOrdinate GetLeftCell(this RobotHardware.IHardwareRobot inRobot)
        {
            CoOrdinate leftCell = new CoOrdinate();

            switch (inRobot.FaceTo)
            {
            case 0:
                leftCell.X = inRobot.X;
                leftCell.Y = inRobot.Y - 1;
                break;

            case 1:
                leftCell.X = inRobot.X + 1;
                leftCell.Y = inRobot.Y;
                break;

            case 2:
                leftCell.X = inRobot.X;
                leftCell.Y = inRobot.Y + 1;
                break;

            case 3:
                leftCell.X = inRobot.X - 1;
                leftCell.Y = inRobot.Y;
                break;
            }
            return(leftCell);
        }
        internal static CoOrdinate GetBackCell(this RobotHardware.IHardwareRobot inRobot)
        {
            CoOrdinate prevCell = new CoOrdinate();

            switch (inRobot.FaceTo)
            {
            case 0:
                prevCell.X = inRobot.X - 1;
                prevCell.Y = inRobot.Y;
                break;

            case 1:
                prevCell.X = inRobot.X;
                prevCell.Y = inRobot.Y - 1;
                break;

            case 2:
                prevCell.X = inRobot.X + 1;
                prevCell.Y = inRobot.Y;
                break;

            case 3:
                prevCell.X = inRobot.X;
                prevCell.Y = inRobot.Y + 1;
                break;
            }
            return(prevCell);
        }
        internal static CoOrdinate GetBottomRightCell(this RobotHardware.IHardwareRobot inRobot)
        {
            CoOrdinate bottomRightCell = new CoOrdinate();

            switch (inRobot.FaceTo)
            {
            case 0:
                bottomRightCell.X = inRobot.X - 1;
                bottomRightCell.Y = inRobot.Y + 1;
                break;

            case 1:
                bottomRightCell.X = inRobot.X - 1;
                bottomRightCell.Y = inRobot.Y - 1;
                break;

            case 2:
                bottomRightCell.X = inRobot.X + 1;
                bottomRightCell.Y = inRobot.Y - 1;
                break;

            case 3:
                bottomRightCell.X = inRobot.X + 1;
                bottomRightCell.Y = inRobot.Y + 1;
                break;
            }
            return(bottomRightCell);
        }
        internal static CoOrdinate GetFrontCell(this RobotHardware.IHardwareRobot inRobot)
        {
            CoOrdinate nextCell = new CoOrdinate();

            switch (inRobot.FaceTo)
            {
            case 0:
                nextCell.X = inRobot.X + 1;
                nextCell.Y = inRobot.Y;
                break;

            case 1:
                nextCell.X = inRobot.X;
                nextCell.Y = inRobot.Y + 1;
                break;

            case 2:
                nextCell.X = inRobot.X - 1;
                nextCell.Y = inRobot.Y;
                break;

            case 3:
                nextCell.X = inRobot.X;
                nextCell.Y = inRobot.Y - 1;
                break;
            }
            return(nextCell);
        }
        internal static CoOrdinate GetCurrentCell(this RobotHardware.IHardwareRobot inRobot)
        {
            CoOrdinate currCell = new CoOrdinate();

            currCell.X = inRobot.X;
            currCell.Y = inRobot.Y;
            return(currCell);
        }
Beispiel #6
0
        virtual public void AddObstacle(CoOrdinate inCoOr)
        {
            CoOrdinate findList = _obstacles.Find(s => ((s.X == inCoOr.X) && (s.Y == inCoOr.Y)));

            if (findList == null)
            {
                _obstacles.Add(inCoOr);
            }
        }
Beispiel #7
0
        public static bool IsCoOrdinatesInLine(CoOrdinate first, CoOrdinate second)
        {
            if (first == null)
            {
                return(false);
            }

            if (second == null)
            {
                return(false);
            }

            return((first.X - second.X == 0) || (first.Y - second.Y == 0));
        }
        static void Main(string[] args)
        {
            // Define the min and max co-ordinate for the room
            CoOrdinate currentRoom = new CoOrdinate(1, 5);

            // Create the Robot
            RobotHardware.IHardwareRobot cleaningRobot = new RobotHardware.Hardware(currentRoom.X, currentRoom.Y);

            // Create the required robot visit monitor. Current visit monitor can print the robot path to console
            IRobotVisitMonitor robotVisitMonitor = RobotVisitMonitorFactory.CreateRobotVisitMonitor(
                RobotVisitMonitorType.RobotVisitMonitorWithConsoleOutput, cleaningRobot);

            // Create a simple room
            Room room = new SimpleRoom();

            // Create the algorithm essentials with the above robot, visit monitor and room.
            AlgorithmEssentials algorithmEssentials = new AlgorithmEssentials(room, cleaningRobot, robotVisitMonitor);

            // Ask the CleaningAlgorithmFactory to create the CleaningAlgorithm instance by passing the required
            // required CleaningAlgorithmType
            CleaningAlgorithm cleaningAlgorithm = CleaningAlgorithmFactory.CreateCleaningAlgorithm(
                CleaningAlgorithmType.CircularCleaningAlgorithm, algorithmEssentials);

            // Ask the ReturnAlgorithmFactory to create the ReturnAlgorithm instance by passing the required
            // required ReturnAlgorithmType
            ReturnAlgorithm returnAlgorithm = ReturnAlgorithmFactory.CreateReturnAlgorithm(
                ReturnAlgorithmType.SimpleReturnAlgorithm, algorithmEssentials);

            // Create a CleaningManager to manage the cleaning and returning process
            CleaningManager manager = new CleaningManager(cleaningAlgorithm, returnAlgorithm);

            bool overallOperationStatus = manager.Clean();

            Console.WriteLine("Cleaning Status : {0}", manager.GetCleanStatus());
            Console.WriteLine("Return Status : {0}", manager.GetReturnStatus());

            robotVisitMonitor.PrintRobotPath();

            Console.ReadKey();
        }
Beispiel #9
0
        private bool IsCellVisited(CoOrdinate inCoOr)
        {
            CoOrdinate findList = _robotVisitList.Find(s => ((s.X == inCoOr.X) && (s.Y == inCoOr.Y)));

            return(findList != null);
        }
Beispiel #10
0
        public bool IsFrontCellVisited()
        {
            CoOrdinate frontCell = _robot.GetFrontCell();

            return(IsCellVisited(frontCell));
        }
 public SimpleRoom()
 {
     _obstacles     = new List <CoOrdinate>();
     _minCoOrdinate = new CoOrdinate(0, 0);
     _maxCoOrdinate = new CoOrdinate(0, 0);
 }