Ejemplo n.º 1
0
 /**
  * @param map
  * @return : the string representation of how given map's regions are connected
  */
 private static String getNeighborsString(Map map) {
   String neighborsString = "setup_map neighbors";
   ArrayList<Point> doneList = new ArrayList<Point>();
   for (Region region : map.regions) {
     int id = region.getId();
     String neighbors = "";
     for (Region neighbor : region.getNeighbors()) {
       if (checkDoneList(doneList, id, neighbor.getId())) {
         neighbors = neighbors.concat("," + neighbor.getId());
         doneList.add(new Point(id, neighbor.getId()));
       }
     }
     if (neighbors.length() != 0) {
       neighbors = neighbors.replaceFirst(",", " ");
       neighborsString = neighborsString.concat(" " + id + neighbors);
     }
   }
   return neighborsString;
 }