/** * @param map * @return : the string representation of given map's regions */ private static String getRegionsString(Map map) { String regionsString = "setup_map regions"; for (Region region : map.regions) { int id = region.getId(); int superRegionId = region.getSuperRegion().getId(); regionsString = regionsString.concat(" " + id + " " + superRegionId); } return regionsString; }
/** * @param map * @return : the string representation of given map's wastelands */ private static String getWastelandsString(Map map) { String wastelandsString = "setup_map wastelands"; for (Region region : map.getRegions()) { if (region.getArmies() > 2) { int id = region.getId(); wastelandsString = wastelandsString.concat(" " + id); } } return wastelandsString; }
/** * @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; }