public double[][] makeWeightedMap() { //Weighted map for road double weightedMap[][] = new double[width][height]; double SEALEVEL = 0; double BEACHLEVEL = 0.05; double PLAINSLEVEL = 0.3; for (int i = 0; i < width / 4; i++) { for (int j = 0; j < height / 4; j++) { weightedMap[i][j] = 0; if (map[i * 4][j * 4] > BEACHLEVEL) { weightedMap[i][j] = 2 + (map[i * 4][j * 4] - PLAINSLEVEL) * 8; } if (map[i][j] <= BEACHLEVEL && map[i * 4][j * 4] >= SEALEVEL) { weightedMap[i][j] = 2 - map[i * 4][j * 4] * 2; } } } CITIES: for (int i = 0; i < CITYAMOUNT; i++) { int px = rng.between(0, width), py = rng.between(0, height), frustration = 0; while (map[px][py] < SEALEVEL || map[px][py] > BEACHLEVEL) { px = rng.between(0, width); py = rng.between(0, height); if(frustration++ > 20) continue CITIES; } cities.add(Coord.get(4 * (px >> 2), 4 * (py >> 2))); } return weightedMap; }
/** * Generates a basic physical map for this world, then overlays a more involved political map with the given number * of factions trying to take land in the world (essentially, nations). The output is a 2D char array where each * letter char is tied to a different faction, while '~' is always water, and '%' is always wilderness or unclaimed * land. A random amount, up to 10% of all land, will be unclaimed wilderness with this method; for more precise * control, use the overload that takes a controlledFraction parameter and give it a value between 0.0 and 1.0, * inclusive. If makeAtlas is true, this also generates an atlas with the procedural names of all the factions and a * mapping to the chars used in the output; the atlas will be in the {@link #atlas} member of this object but will * be empty if makeAtlas has never been true in a call to this. * <br> * If width or height is larger than 256, consider enlarging the Coord pool before calling this with * {@code Coord.expandPoolTo(width, height);}. This will have no effect if width and height are both less than or * equal to 256, but if you expect to be using maps that are especially large (which makes sense for world maps), * expanding the pool will use more memory initially and then (possibly) much less over time, easing pressure on * the garbage collector as well, as re-allocations of large Coords that would otherwise be un-cached are avoided. * @param factionCount the number of factions to have claiming land, cannot be negative or more than 255 * @param makeAtlas if true, this will assign random names to factions, accessible via {@link #atlas} * @return a 2D char array where letters represent the claiming faction, '~' is water, and '%' is unclaimed */ public char[][] generate(int factionCount, boolean makeAtlas) { return generate(factionCount, makeAtlas, false, rng.between(0.9, 1.0), 1.0); } /**
sizeWaterPools = targetWater / rng.between(3, 6), sizeGrassPools = targetGrass / rng.between(2, 5); working.empty().insert(scatter[i]).spill(floors, rng.between(4, Math.min(remainingWater, sizeWaterPools)), rng); if (remainingGrass > 5) //remainingGrass >= targetGrass * 0.02 && working.empty().insert(scatter[i]).spill(floors, rng.between(4, Math.min(remainingGrass, sizeGrassPools)), rng); if (working.isEmpty()) continue;
entries.put(Coord.get(-1, -1), 0.0); for (int i = 0; i < factionCount; i++) { entries.put(map.nth(i), rng.between(0.5, 1.0));
tmpEdge = new GreasedRegion(width, height), tmpInner = new GreasedRegion(width, height), tmpOOB = new GreasedRegion(width, height); Coord[] pts = smallerBounds.randomPortion(rng, rng.between(24, 48)); waterStrength = Math.max(0.0, waterStrength); int aLen = pts.length; entries.put(Coord.get(-1, -1), 0.0); for (int i = 0; i < factionCount; i++) { entries.put(centers[i], rng.between(0.5, 1.0)); OrderedSet<Coord> peaks = new OrderedSet<>(mountains = map.quasiRandomSeparated(0.4, rng.between(100, 150))); int peakCount = peaks.size(); ArrayList<GreasedRegion> groups = new ArrayList<>(peakCount * 3);
entries.put(Coord.get(-1, -1), 0.0); for (int i = 0; i < factionCount; i++) { entries.put(map.nth(i), rng.between(0.5, 1.0));
entries.put(Coord.get(-1, -1), 0.0); for (int i = 0; i < factionCount; i++) { entries.put(map.nth(i), rng.between(0.5, 1.0));