private void MoveRobotOneStepOn(Direction direction) { var x = 0; var y = 0; switch (direction) { case Direction.South: y = -1; break; case Direction.North: y = 1; break; case Direction.East: x = 1; break; case Direction.West: x = -1; break; default: throw new ArgumentOutOfRangeException("direction"); } if (robot.MoveDelta(x, y)) { CleanAtPosition(); } }
public bool MoveDelta(int x, int y) { var currentPosition = engine.CurrentAbsolutePosition; var newPosition = currentPosition.MoveDelta(x, y); if (!grid.isPostionOnGrid(newPosition)) { return(false); } return(engine.MoveDelta(x, y)); }