public static GridPoint MoveRobot( GridPoint initialPoint, RobotDirection robotDirection) { if (RobotDirection.Left.Equals(robotDirection)) { return(initialPoint.MoveLeft(1)); } else if (RobotDirection.Right.Equals(robotDirection)) { return(initialPoint.MoveRight(1)); } else if (RobotDirection.Up.Equals(robotDirection)) { return(initialPoint.MoveUp(1)); } else if (RobotDirection.Down.Equals(robotDirection)) { return(initialPoint.MoveDown(1)); } else { throw new Exception($"Invalid robot direction {robotDirection}"); } }
public void RobotRandomChange() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 2; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.IsTrue(gameModel.isInGame()); RobotDirection prev = gameInfo.robotDir; Assert.AreEqual(gameInfo.robotDir, prev); gameModel.AdvanceTime(this, new System.EventArgs()); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreNotEqual(gameInfo.robotDir, prev); }
public void Place(int positionX, int positionY, RobotDirection direction) { IsPlaced = true; PositionX = positionX; PositionY = positionY; Direction = direction; }
public void ConstructorCheck() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); CrazyBotInfo gameInfo11 = new CrazyBotInfo(11, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); gameModel.newGame(11, gameInfo11); Assert.AreEqual(gameModel.getRobotPos(), gameInfo11.robot); Assert.AreEqual(gameModel.getSize(), 11); Assert.AreEqual(gameInfo11.size, 11); for (int i = 0; i < 10; i++) { int prev = gameModel.getTime(); gameModel.AdvanceTime(this, new System.EventArgs()); if (gameModel.isInGame()) { Assert.IsTrue(prev < gameModel.getTime()); } } }
public RoboChaseInfo(int _size, Position _robot, ulong _time, RobotDirection _rd = RobotDirection.UP, FieldType fieldOnBot = FieldType.NO_WALL, int timeleft = -1) { size = _size; robot = _robot; robotDir = _rd; time = _time; board = new FieldType[size, size]; fieldTypeOnRobot = fieldOnBot; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { board[i, j] = FieldType.NO_WALL; } } board[robot.X, robot.Y] = FieldType.ROBOT; board[size / 2, size / 2] = FieldType.MAGNET; if (timeleft < 0) { Random rand = new Random(); timeLeftUntilCrazy = rand.Next(16); } else { timeLeftUntilCrazy = timeleft; } }
public RobotResultModel(int x, int y, RobotDirection direction) { X = x; Y = y; Direction = direction; DirectionText = direction.ToString(); }
public (int endX, int endY, RobotDirection direction, bool lost) PerformInstructions(MarsGrid grid, RobotInstruction[] instructions) { foreach (var instruction in instructions) { if (instruction == RobotInstruction.Forward) { Move(grid); if (_lost) { break; } } else if (instruction == RobotInstruction.TurnLeft) { _direction = _direction == RobotDirection.North ? RobotDirection.West : _direction - 1; } else if (instruction == RobotInstruction.TurnRight) { _direction = _direction == RobotDirection.West ? RobotDirection.North : _direction + 1; } else { throw new NotImplementedException("Unknown command"); } } return(_coordinates.PositionX, _coordinates.PositionY, _direction, _lost); }
public void WalkOnCannotWall() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); gameModel.AdvanceTime(this, new System.EventArgs()); //Place walls Assert.AreEqual(gameModel.getBoard()[2, 4], FieldType.NO_WALL); gameModel.invertWall(new Position(2, 4)); Assert.AreEqual(gameModel.getBoard()[2, 4], FieldType.WALL); gameInfo.robot = new Position(2, 5); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getBoard()[2, 4], FieldType.CANNOT_WALL); }
public static RobotDirection GetNewRobotDirection( RobotDirection initialRobotDirection, int turnCommand) { // Second, it will output a value indicating the direction the // robot should turn: // 0 means it should turn left 90 degrees, // and 1 means it should turn right 90 degrees. if (turnCommand == 0) { if (RobotDirection.Left.Equals(initialRobotDirection)) { return(RobotDirection.Down); } else if (RobotDirection.Down.Equals(initialRobotDirection)) { return(RobotDirection.Right); } else if (RobotDirection.Right.Equals(initialRobotDirection)) { return(RobotDirection.Up); } else if (RobotDirection.Up.Equals(initialRobotDirection)) { return(RobotDirection.Left); } else { throw new Exception($"Unrecognized initial direction {initialRobotDirection}"); } } else if (turnCommand == 1) { if (RobotDirection.Left.Equals(initialRobotDirection)) { return(RobotDirection.Up); } else if (RobotDirection.Up.Equals(initialRobotDirection)) { return(RobotDirection.Right); } else if (RobotDirection.Right.Equals(initialRobotDirection)) { return(RobotDirection.Down); } else if (RobotDirection.Down.Equals(initialRobotDirection)) { return(RobotDirection.Left); } else { throw new Exception($"Unrecognized initial direction {initialRobotDirection}"); } } else { throw new Exception($"Unrecognized turn command {turnCommand}"); } }
public MarsRobot(int x, int y, RobotDirection direction) { _coordinates = new MarsCoordinates(x, y); _direction = direction; if (_direction == RobotDirection.Unknown) { throw new ArgumentException("Invalid direction"); } }
public Robot(IIntCodeComputer brain, PanelColor startPanelColor) { this.brain = brain; this.direction = RobotDirection.North; this.paintedPanels = new Dictionary <Point, PanelColor>(); this.position = Point.Origin; this.shouldPaint = true; this.startPanelColor = startPanelColor; }
public MartianRobotRotateAction(RobotDirection direction) { if (direction == RobotDirection.Forward) { throw new ArgumentException(nameof(direction)); } this._direction = direction; }
public void HitEdge() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.LEFT; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); RobotDirection prevDir; gameModel.AdvanceTime(this, new EventArgs()); //LEFT gameInfo.robotDir = RobotDirection.LEFT; gameInfo.robot = new Position(1, 1); prevDir = gameInfo.robotDir; gameModel.AdvanceTime(this, new System.EventArgs()); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreNotEqual(prevDir, gameInfo.robotDir); //RIGHT gameInfo.robotDir = RobotDirection.RIGHT; gameInfo.robot = new Position(5, 1); prevDir = gameInfo.robotDir; gameModel.AdvanceTime(this, new System.EventArgs()); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreNotEqual(prevDir, gameInfo.robotDir); //UP gameInfo.robotDir = RobotDirection.UP; gameInfo.robot = new Position(5, 1); prevDir = gameInfo.robotDir; gameModel.AdvanceTime(this, new System.EventArgs()); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreNotEqual(prevDir, gameInfo.robotDir); //DOWN gameInfo.robotDir = RobotDirection.DOWN; gameInfo.robot = new Position(5, 5); prevDir = gameInfo.robotDir; gameModel.AdvanceTime(this, new System.EventArgs()); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreNotEqual(prevDir, gameInfo.robotDir); }
/// <summary> /// Base method for turning arround /// </summary> /// <param name="degree"></param> /// <returns></returns> protected RobotDirection Turn(Func <int> degree, RobotDirection CurrentDirection) { int i = 0; i = (int)CurrentDirection; i += degree(); i = ((i %= 360) <= 0) ? i + 360 : i; return((RobotDirection)i); }
private void Move(RobotMovement movement) { switch (movement) { case RobotMovement.L: if (direction == RobotDirection.E) { direction = RobotDirection.N; } else { direction++; } break; case RobotMovement.R: if (direction == RobotDirection.N) { direction = RobotDirection.E; } else { direction--; } break; case RobotMovement.M: switch (direction) { case RobotDirection.N: y = y < MaxY ? y + 1 : y; break; case RobotDirection.W: x = x > MinX ? x - 1 : MinX; break; case RobotDirection.S: y = y > MinY ? y - 1 : MinY; break; case RobotDirection.E: x = x < MaxX ? x + 1 : x; break; default: break; } break; default: break; } }
private RobotDirection randomiseDirection(RobotDirection except) { Random rand = new Random(); RobotDirection r = (RobotDirection)rand.Next(4); while (r == except) { r = (RobotDirection)rand.Next(4); } return(r); }
public void PlaceWalls() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); //Place walls Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.NO_WALL); gameModel.invertWall(new Position(6, 6)); Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.NO_WALL); gameModel.invertWall(new Position(3, 1)); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.NO_WALL); gameModel.invertWall(new Position(2, 5)); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.WALL); //Try to pick up those walls Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.WALL); gameModel.invertWall(new Position(6, 6)); Assert.AreEqual(gameModel.getBoard()[6, 6], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.WALL); gameModel.invertWall(new Position(3, 1)); Assert.AreEqual(gameModel.getBoard()[3, 1], FieldType.WALL); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.WALL); gameModel.invertWall(new Position(2, 5)); Assert.AreEqual(gameModel.getBoard()[2, 5], FieldType.WALL); //Try place walls on robot and magnet Console.WriteLine(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y].ToString()); Assert.IsTrue(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y] == FieldType.ROBOT); gameModel.invertWall(new Position(gameInfo.robot.X, gameInfo.robot.Y)); Assert.IsTrue(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y] == FieldType.ROBOT); Assert.IsFalse(gameModel.getBoard()[gameInfo.robot.X, gameInfo.robot.Y] == FieldType.WALL); Assert.IsTrue(gameModel.getBoard()[gameModel.getMagnetPos().X, gameModel.getMagnetPos().Y] == FieldType.MAGNET); gameModel.invertWall(new Position(6, 6)); Assert.IsTrue(gameModel.getBoard()[gameModel.getMagnetPos().X, gameModel.getMagnetPos().Y] == FieldType.MAGNET); Assert.IsFalse(gameModel.getBoard()[gameModel.getMagnetPos().X, gameModel.getMagnetPos().Y] == FieldType.WALL); }
public async Task <RoboChaseInfo> LoadAsync(String path) { try { using (StreamReader reader = new StreamReader(path)) { String line = await reader.ReadLineAsync(); int size = Int32.Parse(line); line = await reader.ReadLineAsync(); Position RobotPozition = new Position(Int32.Parse(line.Split(" ")[0]), Int32.Parse(line.Split(" ")[1])); line = await reader.ReadLineAsync(); RobotDirection RobotDir = (RobotDirection)(Int32.Parse(line)); line = await reader.ReadLineAsync(); FieldType fieldTypeOnRobot = (FieldType)Int32.Parse(line); line = await reader.ReadLineAsync(); ulong time = Convert.ToUInt64(line); line = await reader.ReadLineAsync(); int crazyTime = Int32.Parse(line); RoboChaseInfo table = new RoboChaseInfo(size, RobotPozition, time, RobotDir, fieldTypeOnRobot, crazyTime); for (Int32 i = 0; i < size; i++) { line = await reader.ReadLineAsync(); var numbers = line.Split(' '); for (Int32 j = 0; j < size; j++) { table.board[i, j] = (FieldType)(Int32.Parse(numbers[j])); } } return(table); } } catch (Exception e) { throw new FileLoadException(); } }
public void RobotGotMagnet() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.IsTrue(gameModel.isInGame()); gameInfo.robot = new Position(size / 2, (size / 2) + 1); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.IsFalse(gameModel.isInGame()); //11 size = 11; gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); gameModel = new CrazyBotModel(); gameModel.newGame(size, gameInfo); Assert.AreEqual(gameModel.getSize(), 11); Assert.AreEqual(gameInfo.size, 11); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.IsTrue(gameModel.isInGame()); gameInfo.robot = new Position(size / 2, (size / 2) + 1); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.IsFalse(gameModel.isInGame()); //15 size = 15; gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); gameModel = new CrazyBotModel(); gameModel.newGame(size, gameInfo); Assert.AreEqual(gameModel.getSize(), 15); Assert.AreEqual(gameInfo.size, 15); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.IsTrue(gameModel.isInGame()); gameInfo.robot = new Position(size / 2, (size / 2) + 1); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.IsFalse(gameModel.isInGame()); }
public bool EnterArena(IArena arena, uint x, uint y, RobotDirection direction) { if (arena == null || x > arena.UpperLatitude || y > arena.UpperLongitude) { return(false); } this.Arena = arena; this.Latitude = x; this.Longitude = y; this.Direction = direction; return(true); }
/// <summary> /// Enter an arena and go to a specified location /// </summary> /// <param name="arena">Arena to enter</param> /// <param name="x">X coordinate (latitude)</param> /// <param name="y">Y coordinate (longitude)</param> /// <param name="direction"></param> /// <returns>True if arena entered successfully, otherwise false</returns> public bool EnterArena(IArena arena, uint x, uint y, RobotDirection direction) { if (arena == null || x > arena.UpperLatitude || y > arena.UpperLongitude) { return false; } this.Arena = arena; this.Latitude = x; this.Longitude = y; this.Direction = direction; return true; }
private Position oneStepRobot() { RobotDirection rdir = gameInfo.robotDir; Position roboAlgo(int x, int y) { //Check wheter it would get off from the table if (gameInfo.robot.Y + y >= 0 && gameInfo.robot.Y + y < gameInfo.size && gameInfo.robot.X + x >= 0 && gameInfo.robot.X + x < gameInfo.size) { if (getBoard()[gameInfo.robot.X + x, gameInfo.robot.Y + y] == FieldType.WALL) { destructWall(x, y); return(oneStepRobot()); } else { gameInfo.robot.Y += y; gameInfo.robot.X += x; } } else { gameInfo.robotDir = randomiseDirection(gameInfo.robotDir); return(oneStepRobot()); } return(new Position(gameInfo.robot.X + x, gameInfo.robot.Y + y)); } if (rdir == RobotDirection.UP) { return(roboAlgo(0, -1)); } else if (rdir == RobotDirection.DOWN) { return(roboAlgo(0, 1)); } else if (rdir == RobotDirection.LEFT) { return(roboAlgo(-1, 0)); } else if (rdir == RobotDirection.RIGHT) { return(roboAlgo(1, 0)); } return(new Position(0, 0)); }
public void Initialize() { int size = 11; Position robotpos = new Position(8, 7); ulong time = 0; RobotDirection robotdir = RobotDirection.DOWN; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; _mockedTable = new RoboChaseInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); _mock = new Mock <IRoboChaseData>(); _mock.Setup(mock => mock.LoadAsync(It.IsAny <String>())) .Returns(() => Task.FromResult(_mockedTable)); _model = new RoboChaseModel(_mock.Object); }
void UpdateDirection(RobotRotation rotation) { var old = this.direction; if (rotation == RobotRotation.Left) { switch (direction) { case RobotDirection.East: direction = RobotDirection.South; break; case RobotDirection.North: direction = RobotDirection.East; break; case RobotDirection.South: direction = RobotDirection.West; break; case RobotDirection.West: direction = RobotDirection.North; break; } } else { switch (direction) { case RobotDirection.East: direction = RobotDirection.North; break; case RobotDirection.North: direction = RobotDirection.West; break; case RobotDirection.South: direction = RobotDirection.East; break; case RobotDirection.West: direction = RobotDirection.South; break; } } }
public CrazyBotInfo Load(String path) { try { using (StreamReader reader = new StreamReader(path)) // fájl megnyitása { String line = reader.ReadLine(); int size = Int32.Parse(line); line = reader.ReadLine(); Position RobotPozition = new Position(Int32.Parse(line.Split(" ")[0]), Int32.Parse(line.Split(" ")[1])); line = reader.ReadLine(); RobotDirection RobotDir = (RobotDirection)(Int32.Parse(line)); line = reader.ReadLine(); FieldType fieldTypeOnRobot = (FieldType)Int32.Parse(line); line = reader.ReadLine(); ulong time = Convert.ToUInt64(line); line = reader.ReadLine(); int crazyTime = Int32.Parse(line); CrazyBotInfo table = new CrazyBotInfo(size, RobotPozition, time, RobotDir, fieldTypeOnRobot, crazyTime); for (Int32 i = 0; i < size; i++) { line = reader.ReadLine(); var numbers = line.Split(' '); for (Int32 j = 0; j < size; j++) { table.board[i, j] = (FieldType)(Int32.Parse(numbers[j])); } } return(table); } } catch (Exception e) { throw new InvalidOperationException(); } }
/// <summary> /// Put the robot to board (Base Validation) /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="direction"></param> protected bool Place(int x, int y, RobotDirection direction) { if (Board == null) { return(false); } if (x < 0 || y < 0) { return(false); } if (!Board.IsValidPosition(x, y)) { return(false); } Position ??= new RobotPosition(x, y, direction); return(true); }
public override void Process(string command) { Match match; if (!this.Validate(command, out match)) { return; } this.context.LatestRobot = this.context.RobotBuilder.Create(); if (this.context.LatestRobot == null) { return; } uint latitude = Convert.ToUInt32(match.Groups[latitudeGroupName].Value); uint longitude = Convert.ToUInt32(match.Groups[longitudeGroupName].Value); RobotDirection direction = ConvertToDirection(match.Groups[directionGroupName].Value); bool robotCreated = this.context.LatestRobot.EnterArena(this.context.Arena, latitude, longitude, direction); }
public void RotateRight() { var dirs = new List <RobotDirection>() { RobotDirection.Up, RobotDirection.Right, RobotDirection.Down, RobotDirection.Left }; var curindex = dirs.IndexOf(Direction); var newindex = 0; if (curindex == 3) { newindex = 0; } else { newindex = curindex + 1; } Direction = dirs[newindex]; }
public void MoveRighttManyTimesShouldNotBeInvalid(int x, int y, RobotDirection f) { placementRequest = new PlacementRequest { X = x, Y = y, F = f }; using (var sw = new StringWriter()) { Console.SetOut(sw); _theRobot.Place(placementRequest); _theRobot.TurnRight(); _theRobot.TurnRight(); _theRobot.TurnRight(); _theRobot.TurnRight(); _theRobot.TurnRight(); _theRobot.Report(); var report = sw.ToString(); Assert.AreEqual(RobotDirection.SOUTH.ToString(), report.Split(new string[] { ",", ":" }, StringSplitOptions.None)[3].Replace("\n", String.Empty).Replace("\r", String.Empty)); } }
public void MoveRobot() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); gameModel.AdvanceTime(this, new System.EventArgs()); gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Console.WriteLine(gameModel.getRobotPos().X + ", " + gameModel.getRobotPos().Y); Assert.AreEqual(gameModel.getRobotPos(), new Position(1, 0)); gameInfo.robotDir = RobotDirection.DOWN; gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getRobotPos(), new Position(1, 1)); gameInfo.robotDir = RobotDirection.RIGHT; gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getRobotPos(), new Position(2, 1)); gameInfo.robotDir = RobotDirection.LEFT; gameModel.AdvanceTime(this, new System.EventArgs()); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getRobotPos(), new Position(1, 1)); }
public async void SetDirection_Async(RobotDirection direction) { await SetProperty_Async(RobotProperty.direction, direction); }
private string BuildCommand(uint lat, uint lng, RobotDirection direction) { string stringDirection; switch (direction) { case RobotDirection.North: stringDirection = "N"; break; case RobotDirection.South: stringDirection = "S"; break; case RobotDirection.East: stringDirection = "E"; break; default: stringDirection = "W"; break; } return string.Format("{0} {1} {2}", lat, lng, stringDirection); }
private void SetDirection(RobotDirection direction) { this.robot.EnterArena(this.arena.Object, 0, 0, direction); }