Commit 2d109468 by 李进峰

neighbour matrix implement question

parent 20b6149a
......@@ -68,36 +68,43 @@ public class GameEnv implements Serializable{
int x = this.mapNames.get(placeMapTmp.get(tmp));
int y = this.mapNames.get(placeMapTmp.get(idName));
this.mapGraph[x][y] = 1;
// 有方向的添加
// this.mapGraph[y][x] = 1;
}
placeIndex.get(placeMapTmp.get(tmp)).setAbleGo(ableGos);
}
// 映射index -> map name
this.mapIndexName = new String[mapGraph.length];
for(i=0; i<mapGraph.length; i++) {
for(String mapName:mapNames.keySet()) {
if(mapNames.get(mapName).equals(i)) {
System.out.print(mapName+"\t");
mapIndexName[i] = mapName;
}
}
}
// 映射index -> map name
this.mapIndexName = new String[mapGraph.length];
System.out.println("\n");
System.out.print("\t");
for(i=0; i<mapGraph.length; i++) {
for(String mapName:mapNames.keySet()) {
if(mapNames.get(mapName).equals(i)) {
mapIndexName[i] = mapName;
System.out.print(mapName+"\t");
}
}
}
// for(i=0; i<this.mapGraph.length; i++) {
// for(String mapName:mapNames.keySet()) {
// if(mapNames.get(mapName).equals(i)) {
// System.out.print(mapName+"\t");
// }
// }
// for(int j=0; j<this.mapGraph[i].length; j++) {
// System.out.print(this.mapGraph[i][j]+"\t");
// }
// System.out.print("\n\n");
// }
System.out.print("\n");
for(i=0; i<this.mapGraph.length; i++) {
for(String mapName:mapNames.keySet()) {
if(mapNames.get(mapName).equals(i)) {
System.out.print(mapName+"\t");
}
}
for(int j=0; j<this.mapGraph[i].length; j++) {
System.out.print(this.mapGraph[i][j]+"\t");
}
System.out.print("\n\n");
}
}
// npc
// npc class
......@@ -282,10 +289,11 @@ public class GameEnv implements Serializable{
// 我现在能去哪
public List<String> queryCanGoBySite(String site){
List<String> ableGoString = new ArrayList<String>();
Place place = this.placeIndex.get(site);
List<Place> ableGos = place.getAbleGo();
for(int i=0; i<ableGos.size(); i++) {
ableGoString.add(ableGos.get(i).getName());
int x = this.mapNames.get(site);
for(int i=0; i<this.mapGraph[x].length; i++) {
if(this.mapGraph[x][i]==1) {
ableGoString.add(this.mapIndexName[i]);
}
}
return ableGoString;
}
......@@ -297,9 +305,9 @@ public class GameEnv implements Serializable{
int x = this.mapNames.get(placeA);
int y = this.mapNames.get(placeB);
if(this.mapGraph[x][y] == 1) {
return 2;
}else {
return 1;
}else {
return 2;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment