From 2d27371491ca403f1fb5c2b435d4d8c0c31c1f87 Mon Sep 17 00:00:00 2001 From: jzhou Date: Wed, 3 Sep 2008 01:47:03 +0000 Subject: [PATCH] use more sophiscated strategy for character moving --- Robust/src/Benchmarks/MMG/Java/Ghost.java | 6 +++++- Robust/src/Benchmarks/MMG/Nor/Ghost.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Robust/src/Benchmarks/MMG/Java/Ghost.java b/Robust/src/Benchmarks/MMG/Java/Ghost.java index 9e5659fa..0d057a36 100755 --- a/Robust/src/Benchmarks/MMG/Java/Ghost.java +++ b/Robust/src/Benchmarks/MMG/Java/Ghost.java @@ -83,7 +83,7 @@ public class Ghost { int tmpdirection = 0; boolean first = true; while(!set) { - int parents[] = new int[this.m_map.m_nrofblocks * this.m_map.m_nrofblocks]; + int parents[] = new int[this.m_map.m_nrofblocks * this.m_map.m_nrofblocks + 1]; for(int i = 0; i < parents.length; i++) { parents[i] = -1; } @@ -155,6 +155,7 @@ public class Ghost { // Array parents records parent for a node in the BFS search // Vector cuts specifies which nodes can not be the first one to access in this BFS private boolean BFS(Node start, Node end, int[] parents, Vector cuts) { + int steps = 0; Vector toaccess = new Vector(); toaccess.addElement(start); while(toaccess.size() > 0) { @@ -163,8 +164,10 @@ public class Ghost { toaccess.removeElementAt(0); if(access.getIndex() == end.getIndex()) { // hit the end node + parents[parents.length - 1] = steps; return true; } + steps++; Vector neighbours = access.getNeighbours(); for(int i = 0; i < neighbours.size(); i++) { Node neighbour = (Node)neighbours.elementAt(i); @@ -189,6 +192,7 @@ public class Ghost { } } } + parents[parents.length - 1] = -1; return false; } diff --git a/Robust/src/Benchmarks/MMG/Nor/Ghost.java b/Robust/src/Benchmarks/MMG/Nor/Ghost.java index b813147e..228e6d8a 100755 --- a/Robust/src/Benchmarks/MMG/Nor/Ghost.java +++ b/Robust/src/Benchmarks/MMG/Nor/Ghost.java @@ -85,7 +85,7 @@ public class Ghost { int tmpdirection = 0; boolean first = true; while(!set) { - int parents[] = new int[this.m_map.m_nrofblocks * this.m_map.m_nrofblocks]; + int parents[] = new int[this.m_map.m_nrofblocks * this.m_map.m_nrofblocks + 1]; for(int i = 0; i < parents.length; i++) { parents[i] = -1; } @@ -157,6 +157,7 @@ public class Ghost { // Array parents records parent for a node in the BFS search // Vector cuts specifies which nodes can not be the first one to access in this BFS private boolean BFS(Node start, Node end, int[] parents, Vector cuts) { + int steps = 0; Vector toaccess = new Vector(); toaccess.addElement(start); while(toaccess.size() > 0) { @@ -165,8 +166,10 @@ public class Ghost { toaccess.removeElementAt(0); if(access.getIndex() == end.getIndex()) { // hit the end node + parents[parents.length - 1] = steps; return true; } + steps++; Vector neighbours = access.getNeighbours(); for(int i = 0; i < neighbours.size(); i++) { Node neighbour = (Node)neighbours.elementAt(i); @@ -191,6 +194,7 @@ public class Ghost { } } } + parents[parents.length - 1] = -1; return false; } -- 2.34.1