Commit 669b44ce by 李进峰

add nickname find placename

parent 0fcd792a
......@@ -329,6 +329,21 @@ public class GameEnv implements Serializable{
return 2;
}
}
// 通过别名查询当前地点最近的别名地点
public String getPlaceNameByNickname(String curPlaceName, String nickname) {
if(this.placeIndex.get(curPlaceName).getNickname().indexOf(nickname)>=0) {
return curPlaceName;
}else {
List<String> placePath = getAllPath(curPlaceName, nickname);
if(placePath.size()>=2) {
return placePath.get(placePath.size()-1);
}else {
return nickname;
}
}
}
// 两点之间的路径 // 使用广度优先算法单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。
public List<String> getAllPath(String placeA, String placeB){
List<String> paths = new ArrayList<String>();
......
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