From cb8c2eadab02a25f3ec7c6eac1348b8c0f9d055c Mon Sep 17 00:00:00 2001 From: David Ayers Date: Sat, 28 Dec 2013 17:48:08 -0600 Subject: [PATCH 1/3] Fixed KeyNotFoundException when re-prioritizing a node in the frontier --- .gitignore | 1 + pathfinding/ShortestPathGraphSearch.cs | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .gitignore 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..8c71abe 100644 --- a/pathfinding/ShortestPathGraphSearch.cs +++ b/pathfinding/ShortestPathGraphSearch.cs @@ -114,6 +114,8 @@ 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; } } } From a0b590677188e4abd3b4d1bedfbb375cdab88adc Mon Sep 17 00:00:00 2001 From: David Ayers Date: Thu, 6 Feb 2014 21:49:43 -0600 Subject: [PATCH 2/3] Removed unnecessary "new" from non overriden methods --- unittest/UUnitAssert.cs | 2 +- unittest/UUnitTestResult.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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+" "; From 587f39831ef7338c82fb198d3f8dcda25ff579e7 Mon Sep 17 00:00:00 2001 From: David Ayers Date: Tue, 3 Jan 2017 18:56:53 -0600 Subject: [PATCH 3/3] Add shortcuit to pathfinder --- pathfinding/ShortestPathGraphSearch.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pathfinding/ShortestPathGraphSearch.cs b/pathfinding/ShortestPathGraphSearch.cs index 8c71abe..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); @@ -119,6 +121,12 @@ public List GetShortestPath(State fromState, State toState){ } } } + + if (shortCircuit > 3000) + { + DebugLog.Log("Short circuiting pathfinder, took more than 3000 tries"); + break; + } } return null;