diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6bb293 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.meta diff --git a/pathfinding/ShortestPathGraphSearch.cs b/pathfinding/ShortestPathGraphSearch.cs index eda17b0..6ca6abf 100644 --- a/pathfinding/ShortestPathGraphSearch.cs +++ b/pathfinding/ShortestPathGraphSearch.cs @@ -85,8 +85,10 @@ public List GetShortestPath(State fromState, State toState){ #endif frontierMap.Add(fromState, startNode); - - while (!frontier.IsEmpty){ + int shortCircuit = 0; + while (!frontier.IsEmpty) + { + shortCircuit++; SearchNode node = frontier.Dequeue(); frontierMap.Remove(node.state); @@ -114,9 +116,17 @@ public List GetShortestPath(State fromState, State toState){ #else frontier.Replace(frontierNode,frontierNode.f, searchNode.f); #endif + // reset f on the frontier node to made it's new position in the priority queue + frontierNode.f = searchNode.f; } } } + + if (shortCircuit > 3000) + { + DebugLog.Log("Short circuiting pathfinder, took more than 3000 tries"); + break; + } } return null; diff --git a/unittest/UUnitAssert.cs b/unittest/UUnitAssert.cs index 1018e7a..1ff49e5 100755 --- a/unittest/UUnitAssert.cs +++ b/unittest/UUnitAssert.cs @@ -53,7 +53,7 @@ public static void Equals(object expected, object actual, string msg){ Error(expected, actual, msg); } - public static new void Equals(Vector3 expected, Vector3 actual){ + public static void Equals(Vector3 expected, Vector3 actual){ Equals(expected, actual,""); } diff --git a/unittest/UUnitTestResult.cs b/unittest/UUnitTestResult.cs index b97984c..ee49fae 100755 --- a/unittest/UUnitTestResult.cs +++ b/unittest/UUnitTestResult.cs @@ -74,7 +74,7 @@ public TestResultEntry(string className, string methodName,bool success,UUnitAss this.errormsg = errormsg; } - public new string ToString(bool shortSummary = false){ + public string ToString(bool shortSummary = false){ string res = (success? "SUCCESS ": "FAIL ")+className+"."+methodName+" duration: "+duration+" ";