public void MapWithLockedDoorAndNoCluesIsNotSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoorAndClues(new DoorRequirements(new Connection(10, 11), "lock0"), new List<int>()); GraphSolver solver = new GraphSolver(mapModel); Assert.IsFalse(solver.MapCanBeSolved()); }
public void MapWithLockedDoorAndRecursivelyLockedTwoCluesIsSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoorAndClues(new DoorRequirements(new Connection(10, 11), "lock0"), new List<int>(new int[] { 6 })); doorManager.PlaceDoorAndClues(new DoorRequirements(new Connection(5, 6), "lock1"), new List<int>(new int[] { 4 })); GraphSolver solver = new GraphSolver(mapModel); Assert.IsTrue(solver.MapCanBeSolved()); }
public bool DoLockClueStressTest(int numberOfNodes, double branchingRatio, int numberOfDoors, int numberOfCluesPerDoor, bool visualise) { var graphGenerator = new GraphGenerator(random); var randomMap = graphGenerator.GenerateConnectivityMapNoCycles(numberOfNodes, branchingRatio); var doorAndClueTester = new DoorAndObjectiveGenerator(random); var mapModel = new MapModel(randomMap, 0); if (visualise) VisualiseConnectivityGraph(mapModel); doorAndClueTester.AddDoorsAndObjectives(mapModel, numberOfDoors, numberOfCluesPerDoor); if (visualise) VisualiseConnectivityGraphWithDoors(mapModel); var mapTester = new GraphSolver(mapModel); return mapTester.MapCanBeSolved(); }
public void MapWithLockedDoorDependingOnAnObjectiveWithNotEnoughCluesIsNotSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoor(new DoorRequirements(new Connection(10, 11), "lock0", 2)); doorManager.PlaceObjective(new ObjectiveRequirements(2, "obj0", 1, new List<string> { "lock0" })); //red herring doorManager.PlaceObjective(new ObjectiveRequirements(3, "obj1", 1)); //One clue before and one after the door (not enough to unlock it) var clues = doorManager.AddCluesToExistingObjective("obj0", new List<int> { 2 }); GraphSolver solver = new GraphSolver(mapModel); Assert.IsFalse(solver.MapCanBeSolved()); }
public void MapWithNoDoorsIsSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); GraphSolver solver = new GraphSolver(mapModel); Assert.IsTrue(solver.MapCanBeSolved()); }
public void MapWithLockedDoorWithRecursiveDependencyOnObjectiveIsSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoor(new DoorRequirements(new Connection(10, 11), "lock0", 1)); doorManager.PlaceObjective(new ObjectiveRequirements(4, "obj0", 1, new List<string> { "lock0" })); doorManager.PlaceObjective(new ObjectiveRequirements(4, "obj1", 1, new List<string> { "obj0" })); doorManager.AddCluesToExistingObjective("obj1", new List<int> { 1 }); GraphSolver solver = new GraphSolver(mapModel); Assert.IsTrue(solver.MapCanBeSolved()); }
public void MapWithLockedDoorWithDependencyOnUnsolveableObjectiveIsNotSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoor(new DoorRequirements(new Connection(10, 11), "lock0", 1)); doorManager.PlaceObjective(new ObjectiveRequirements(4, "obj0", 1, new List<string> { "lock0" })); //missing clue for objective GraphSolver solver = new GraphSolver(mapModel); Assert.IsFalse(solver.MapCanBeSolved()); }