public void CircleRadiusAreaProvider() { bool[,] radius = new bool[30, 30]; // Initted to false var radAProv = new RadiusAreaProvider(Coord.Get(15, 15), 10, Radius.CIRCLE); foreach (var pos in radAProv.CalculatePositions()) { radius[pos.X, pos.Y] = true; } for (int y = 0; y < radius.GetLength(1); y++) { for (int x = 0; x < radius.GetLength(0); x++) { if (radius[x, y]) { Console.Write("1 "); } else { Console.Write("0 "); } } Console.WriteLine(); } Assert.AreEqual(true, true); }
public void SquareRadiusArea() { bool[,] radius = new bool[30, 30]; // Initted to false var radAProv = new RadiusAreaProvider(Coord.Get(15, 15), 10, Radius.SQUARE); foreach (var pos in radAProv.CalculatePositions()) { radius[pos.X, pos.Y] = true; } for (int y = 0; y < radius.GetLength(1); y++) { for (int x = 0; x < radius.GetLength(0); x++) { if (radius[x, y]) { Console.Write("1 "); } else { Console.Write("0 "); } } Console.WriteLine(); } double maxDistance = 0; foreach (var pos in radAProv.CalculatePositions()) { double distFromCenter = Distance.CHEBYSHEV.Calculate(Coord.Get(15, 15), pos); if (distFromCenter < maxDistance) { Assert.Fail("Square radius area provider isn't returning in distance order!"); } maxDistance = Math.Max(maxDistance, distFromCenter); } }
private bool testSenseMap(SourceType algorithm, Radius shape) { var map = rectResMap(MAP_WIDTH, MAP_HEIGHT); // Start out at false bool[,] radiusMap = new bool[MAP_WIDTH, MAP_HEIGHT]; bool[,] losMap = new bool[MAP_WIDTH, MAP_HEIGHT]; var los = new SenseMap(map); var lightSource = new SenseSource(algorithm, CENTER, RADIUS_LEGNTH, shape); los.AddSenseSource(lightSource); los.Calculate(); for (int x = 0; x < MAP_WIDTH; x++) { for (int y = 0; y < MAP_HEIGHT; y++) { if (los[x, y] > 0) { losMap[x, y] = true; } } } var radArea = new RadiusAreaProvider(CENTER, RADIUS_LEGNTH, shape); foreach (var pos in radArea.CalculatePositions()) { radiusMap[pos.X, pos.Y] = true; } Console.WriteLine("Radius Shape: "); printArray(radiusMap); Console.WriteLine("LOS Shape: "); printArray(losMap); return(equivalentArrays(radiusMap, losMap)); }