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); }
public void CircularCleaningAlgorithmOnSquareShapeTest() { // Define the min and max co-ordinate for the room _currentRoom = new CoOrdinate(3, 3); // Create the Robot _cleaningRobot = new RobotHardware.Hardware(_currentRoom.X, _currentRoom.Y); // Create the required robot visit monitor. Current visit monitor can print the robot path to console _robotVisitMonitor = RobotVisitMonitorFactory.CreateRobotVisitMonitor( RobotVisitMonitorType.RobotVisitMonitorWithConsoleOutput, _cleaningRobot); // Create a simple room _room = new SimpleRoom(); // Create the algorithm essentials with the above robot, visit monitor and room. _algorithmEssentials = new AlgorithmEssentials(_room, _cleaningRobot, _robotVisitMonitor); // Ask the CleaningAlgorithmFactory to create the CleaningAlgorithm instance by passing the required // required CleaningAlgorithmType _cleaningAlgorithm = CleaningAlgorithmFactory.CreateCleaningAlgorithm( CleaningAlgorithmType.CircularCleaningAlgorithm, _algorithmEssentials); Assert.AreEqual(CleanStatus.Complete, _cleaningAlgorithm.Clean()); Assert.AreEqual("Turn Left", _algorithmEssentials.RobotVisitMonitor.GetPathAt(0)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(1)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(2)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(3)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(4)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(5)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(6)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(7)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(8)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(9)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(10)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(11)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(12)); Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(13)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(14)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(15)); Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(16)); }
public static IRobotVisitMonitor CreateRobotVisitMonitor(RobotVisitMonitorType inRobotVisitMonitorType, RobotHardware.IHardwareRobot inRobot) { IRobotVisitMonitor robotVisitMonitor; switch (inRobotVisitMonitorType) { case RobotVisitMonitorType.RobotVisitMonitorWithConsoleOutput: robotVisitMonitor = new RobotVisitMonitorWithConsoleOutput(inRobot); break; default: robotVisitMonitor = null; break; } return(robotVisitMonitor); }
public AlgorithmEssentials(Room inRoom, RobotHardware.IHardwareRobot inRobot, IRobotVisitMonitor inRobotVisitMonitor) { _room = inRoom; _robot = inRobot; _robotVisitMonitor = inRobotVisitMonitor; }
public RobotVisitMonitorWithConsoleOutput(RobotHardware.IHardwareRobot inRobot) { _robotVisitList = new List <CoOrdinate>(); _robot = inRobot; _pathLogger = new List <string>(); }