本文整理汇总了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());
}
示例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());
}
示例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);
}
示例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()}");
}
示例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");
}
示例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);
}
示例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();
}
示例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());
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}