当前位置: 首页>>代码示例>>C#>>正文


C# Robot.Move方法代码示例

本文整理汇总了C#中Robot.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Robot.Move方法的具体用法?C# Robot.Move怎么用?C# Robot.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Robot的用法示例。


在下文中一共展示了Robot.Move方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestRetraceSteps

        public void TestRetraceSteps()
        {
            Robot robot = new Robot(new Vector2(-10, -10));
            PositionTracker tracker = new PositionTracker(robot);

            robot.Move(new Vector2(10, 0));
            robot.Move(new Vector2(-11, 0));

            Assert.AreEqual(12, tracker.CalculatePositionsVisited());
        }
开发者ID:jacob-ebey,项目名称:RobotCleaner,代码行数:10,代码来源:PositionTrackerTests.cs

示例2: TestPositionTrackerCalculationNegativeStart

        public void TestPositionTrackerCalculationNegativeStart()
        {
            Robot robot = new Robot(new Vector2(-10, -10));
            PositionTracker tracker = new PositionTracker(robot);

            robot.Move(new Vector2(2, 0));
            robot.Move(new Vector2(0, 2));
            robot.Move(new Vector2(-2, 0));
            robot.Move(new Vector2(0, -2));

            Assert.AreEqual(8, tracker.CalculatePositionsVisited());
        }
开发者ID:jacob-ebey,项目名称:RobotCleaner,代码行数:12,代码来源:PositionTrackerTests.cs

示例3: TestRobotMove

        public void TestRobotMove()
        {
            Robot robot = new Robot(new Vector2(10, 11));

            robot.Move(new Vector2(10, 0));
            Assert.AreEqual(20, robot.Position.X);
            Assert.AreEqual(11, robot.Position.Y);

            robot.Move(new Vector2(0, 11));
            Assert.AreEqual(20, robot.Position.X);
            Assert.AreEqual(22, robot.Position.Y);

            robot.Move(new Vector2(-10, -11));
            Assert.AreEqual(10, robot.Position.X);
            Assert.AreEqual(11, robot.Position.Y);
        }
开发者ID:jacob-ebey,项目名称:RobotCleaner,代码行数:16,代码来源:RobotTests.cs

示例4: Main

        static void Main(string[] args)
        {
            // Read the count of the commands that will follow.
            int commandCount = int.Parse(Console.ReadLine());
            
            // Get the start position of the robot.
            Vector2 startPosition = Vector2.PositionFromString(Console.ReadLine());

            // Create the robot and the tracker.
            Robot robot = new Robot(startPosition);
            PositionTracker tracker = new PositionTracker(robot);

            // Loop until we have read all commands.
            for (int i = 0; i < commandCount; i++)
            {
                // Read the line and create a movement vector.
                var line = Console.ReadLine();
                Vector2 movement = Vector2.MoveDirectionFromString(line);

                // Move the robot.
                robot.Move(movement);
            }

            // Calculate and display the unique positions visited by the robot.
            Console.WriteLine($"=> Cleaned: {tracker.CalculatePositionsVisited()}");
        }
开发者ID:jacob-ebey,项目名称:RobotCleaner,代码行数:26,代码来源:Program.cs

示例5: ExecuteAction

        public override void ExecuteAction(Robot.hexapod hexy)
        {
            var deg = -30;
            hexy.LeftFront.hip(-deg);
            hexy.RightMiddle.hip(1);
            hexy.LeftBack.hip(deg);

            hexy.RightFront.hip(deg);
            hexy.LeftMiddle.hip(1);
            hexy.RightBack.hip(-deg);

            Thread.Sleep(500);

            foreach (var leg in hexy.Legs)
            {
                leg.knee(-30);
            }

            Thread.Sleep(500);

            for (var angle = 0; angle <= 45; angle += 3)
            {
                foreach (var leg in hexy.Legs)
                {
                    leg.knee(angle);
                    leg.ankle(-90 + angle);
                }
                Thread.Sleep(100);
            }

            hexy.Move("Reset");
        }
开发者ID:Togusa09,项目名称:Hexy,代码行数:32,代码来源:GetUp.cs

示例6: MovesOneStepAccordingToHeading

        public void MovesOneStepAccordingToHeading()
        {
            var robot = new Robot(new Point(0, 0), Heading.FromChar('N'));
            robot.Move();

            Assert.Equal(0, robot.Position.X);
            Assert.Equal(1, robot.Position.Y);
        }
开发者ID:jasonmitchell,项目名称:robot-wars,代码行数:8,代码来源:RobotFacts.cs

示例7: GoForwardButNowIsHeadingWestEdgeShouldThrowException

        public void GoForwardButNowIsHeadingWestEdgeShouldThrowException()
        {
            IPosition position = new Position(0, 0);
            IHeading heading = new HeadingWest();
            IList<char> MovingInstruction = new List<char>();
            MovingInstruction.Add('M');

            var robot = new Robot(0, position, heading, MovingInstruction, _targetPlateau);
            robot.Move();
        }
开发者ID:iworm,项目名称:marsexplorer,代码行数:10,代码来源:MoveTest.cs

示例8: GoForwardToEast

        public void GoForwardToEast()
        {
            IPosition position = new Position(1, 2);
            IHeading heading = new HeadingEast();
            IList<char> MovingInstruction = new List<char>();
            MovingInstruction.Add('M');

            var robot = new Robot(0, position, heading, MovingInstruction, _targetPlateau);
            robot.Move();

            Assert.AreEqual(2, robot.CurrentPosition.X);
            Assert.AreEqual(2, robot.CurrentPosition.Y);
            Assert.AreEqual(typeof(HeadingEast), robot.Heading.GetType());
        }
开发者ID:iworm,项目名称:marsexplorer,代码行数:14,代码来源:MoveTest.cs

示例9: Given_Move_Is_Not_Valid_For_StartPosition_Then_Throw_InvalidOperationException

        public void Given_Move_Is_Not_Valid_For_StartPosition_Then_Throw_InvalidOperationException()
        {
            // ARRANGE
            var arena = new RectangleArena();
            arena.SetArenaSize(1, 1);

            var robot = new Robot(arena);
            robot.SetStartPosition(new Position(1, 1, Orientation.North));

            // ACT
            robot.Move(Motion.Forward);
        }
开发者ID:chriscartlidge,项目名称:CodeKata.RobotWars,代码行数:12,代码来源:RobotTests.cs

示例10: InvalidMoveInstructionShouldThrowException

        public void InvalidMoveInstructionShouldThrowException()
        {
            IPosition position = new Position(1, 2);
            IHeading heading = new HeadingWest();
            IList<char> MovingInstruction = new List<char>();
            MovingInstruction.Add('T');

            var robot = new Robot(0, position, heading, MovingInstruction, _targetPlateau);
            robot.Move();
        }
开发者ID:iworm,项目名称:marsexplorer,代码行数:10,代码来源:MoveTest.cs

示例11: NotListenReportedPosition

 public void NotListenReportedPosition()
 {
     Robot robot = new Robot(0, new Position(1, 1), new HeadingEast(), new List<char>() { 'M' }, new Plateau(5, 5));
     robot.Move();
 }
开发者ID:iworm,项目名称:marsexplorer,代码行数:5,代码来源:ReportedPositionTest.cs

示例12: ListenReportedPosition

 public void ListenReportedPosition()
 {
     Robot robot = new Robot(0, new Position(1, 1), new HeadingEast(), new List<char>() { 'M' }, new Plateau(5, 5));
     robot.ReportedPosition += (id, position, heading) => Assert.Pass();
     robot.Move();
 }
开发者ID:iworm,项目名称:marsexplorer,代码行数:6,代码来源:ReportedPositionTest.cs


注:本文中的Robot.Move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。