public void Can_Run_A_Robot_Through_A_Game_And_Get_A_Score() { IDictionary <Situation, RobotAction> moveStrategy = StrategyGenerator.Random(); Scorer scorer = new Scorer(); Robot robot = new Robot(moveStrategy, scorer); Board board = new Board(10, 10); var litterer = new BoardLitterer(0.5); litterer.Litter(board); board.AddElement(robot, new Point(0, 0)); const int numberOfTurns = 200; for (int i = 0; i < numberOfTurns; i++) { robot.Act(board); } int score = robot._scorer.Score; Debug.Print("Score is: {0}", score); }
public void Robbie_Can_Hit_Wall() { IDictionary <Situation, RobotAction> moveNorthStrategy = GetSimpleStrategy(RobotAction.MoveNorth); Robot robbie = new Robot(moveNorthStrategy); Board board = new Board(10, 10); Point initialPos = new Point(0, 0); board.AddElement(robbie, initialPos); robbie.Act(board); Assert.IsTrue(board.Contents(initialPos).Contains(robbie)); }
public void Robot_Can_Move() { IDictionary <Situation, RobotAction> alwaysMoveSouthStrategy = GetSimpleStrategy(RobotAction.MoveSouth); Robot robbie = new Robot(alwaysMoveSouthStrategy); Board board = new Board(10, 10); Point initialPos = new Point(0, 0); board.AddElement(robbie, initialPos); robbie.Act(board); Assert.IsFalse(board.Contents(initialPos).Contains(robbie)); Assert.IsTrue(board.Contents(initialPos + new Point(1, 0)).Contains(robbie)); }
public void Robbie_Can_Do_Nothing() { IDictionary <Situation, RobotAction> stayPutStrategy = GetSimpleStrategy(RobotAction.StayPut); Robot robbie = new Robot(stayPutStrategy); Board board = new Board(10, 10); Point initialPos = new Point(0, 0); board.AddElement(robbie, initialPos); Assert.IsTrue(board.Contents(initialPos).Contains(robbie)); robbie.Act(board); Assert.IsTrue(board.Contents(initialPos).Contains(robbie)); }
public void Robbie_Can_Fail_To_Pickup_Rubbish() { IDictionary <Situation, RobotAction> pickupStrategy = GetSimpleStrategy(RobotAction.PickUpCan); Robot robbie = new Robot(pickupStrategy); Board board = new Board(10, 10); Point initialPos = new Point(0, 0); board.AddElement(robbie, initialPos); Assert.IsTrue(board.Contents(initialPos).Contains(robbie)); robbie.Act(board); Assert.IsTrue(board.Contents(initialPos).Contains(robbie)); }