public void CheckPathsOnTheeByThree() { double[,] array = new double[3, 3]; array[0, 0] = 1; array[0, 1] = 2; array[1, 0] = 2; array[1, 1] = 3; array[0, 2] = 3; array[2, 0] = 3; array[1, 2] = 4; array[2, 1] = 4; array[2, 2] = 5; GridSearcher gs = new GridSearcher(array, 15); List <Path> paths = gs.Search(); Assert.IsNotNull(paths); Assert.AreEqual(19, paths.Count); Assert.AreEqual(6, paths.FindAll(item => item.IsCompletePath()).Count); Assert.AreEqual(6, paths.FindAll(item => item.IsValidPath()).Count); Assert.AreEqual("Coords: (0, 0), Value: 1, Coords: (1, 0), Value: 2, Coords: (2, 0), Value: 3, Coords: (2, 1), Value: 4, Coords: (2, 2), Value: 5, Sum: 15", paths.FindAll(item => item.IsValidPath())[0].ToString()); Assert.AreEqual("Coords: (0, 0), Value: 1, Coords: (1, 0), Value: 2, Coords: (1, 1), Value: 3, Coords: (2, 1), Value: 4, Coords: (2, 2), Value: 5, Sum: 15", paths.FindAll(item => item.IsValidPath())[1].ToString()); Assert.AreEqual("Coords: (0, 0), Value: 1, Coords: (1, 0), Value: 2, Coords: (1, 1), Value: 3, Coords: (1, 2), Value: 4, Coords: (2, 2), Value: 5, Sum: 15", paths.FindAll(item => item.IsValidPath())[2].ToString()); Assert.AreEqual("Coords: (0, 0), Value: 1, Coords: (0, 1), Value: 2, Coords: (1, 1), Value: 3, Coords: (2, 1), Value: 4, Coords: (2, 2), Value: 5, Sum: 15", paths.FindAll(item => item.IsValidPath())[3].ToString()); Assert.AreEqual("Coords: (0, 0), Value: 1, Coords: (0, 1), Value: 2, Coords: (1, 1), Value: 3, Coords: (1, 2), Value: 4, Coords: (2, 2), Value: 5, Sum: 15", paths.FindAll(item => item.IsValidPath())[4].ToString()); Assert.AreEqual("Coords: (0, 0), Value: 1, Coords: (0, 1), Value: 2, Coords: (0, 2), Value: 3, Coords: (1, 2), Value: 4, Coords: (2, 2), Value: 5, Sum: 15", paths.FindAll(item => item.IsValidPath())[5].ToString()); }
public void CheckPathsOnActualProblem() { double[,] array = GetArray(); GridSearcher gs = new GridSearcher(array, 1); List <Path> paths = gs.Search(); Assert.IsNotNull(paths); Assert.AreEqual(1, paths.FindAll(item => item.IsValidPath()).Count); Assert.AreEqual("Coords: (0, 0), Value: 0.02, Coords: (1, 0), Value: 0.2, Coords: (2, 0), Value: 0.005, Coords: (2, 1), Value: 0.04, Coords: (2, 2), Value: 0.2, Coords: (3, 2), Value: 0.05, Coords: (4, 2), Value: 0.001, Coords: (4, 3), Value: 0.05, Coords: (4, 4), Value: 0.015, Coords: (5, 4), Value: 0.199, Coords: (5, 5), Value: 0.01, Coords: (6, 5), Value: 0.08, Coords: (6, 6), Value: 0.02, Coords: (6, 7), Value: 0.02, Coords: (7, 7), Value: 0.09, Sum: 1", paths.FindAll(item => item.IsValidPath())[0].ToString()); }
public void CheckPathsOnTinyArray() { double[,] array = new double[1, 1]; GridSearcher gs = new GridSearcher(array, 1); List <Path> paths = gs.Search(); Assert.IsNotNull(paths); Assert.AreEqual(1, paths.Count); }
public void CheckGetSum() { double[,] array = new double[2, 2]; array[0, 0] = 1; array[0, 1] = 2; array[1, 0] = 2; array[1, 1] = 3; GridSearcher gs = new GridSearcher(array, 6); List <Path> paths = gs.Search(); Assert.IsNotNull(paths); Assert.AreEqual(5, paths.Count); Assert.AreEqual(1, paths[0].GetSum()); Assert.AreEqual(3, paths[1].GetSum()); Assert.AreEqual(6, paths[2].GetSum()); Assert.AreEqual(3, paths[3].GetSum()); Assert.AreEqual(6, paths[4].GetSum()); }
public void CheckPathsOnTwoByTwo() { double[,] array = new double[2, 2]; GridSearcher gs = new GridSearcher(array, 1); List <Path> paths = gs.Search(); Assert.IsNotNull(paths); Assert.AreEqual(5, paths.Count); Assert.AreEqual(1, paths[0].PathCount); Assert.AreEqual(2, paths[1].PathCount); Assert.AreEqual(3, paths[2].PathCount); Assert.AreEqual(2, paths[3].PathCount); Assert.AreEqual(3, paths[4].PathCount); Assert.IsFalse(paths[0].IsCompletePath()); Assert.IsFalse(paths[1].IsCompletePath()); Assert.IsTrue(paths[2].IsCompletePath()); Assert.IsFalse(paths[3].IsCompletePath()); Assert.IsTrue(paths[4].IsCompletePath()); }
private void FindPath() { GridSearcher.FindPath(transform.position, target.position, pathResult); }