public MetsaMapFactory(int width, int height) { this(width, height, new StatefulRNG()); } public MetsaMapFactory(int width, int height, long rngSeed)
/** * Make a SectionDungeonGenerator with a LightRNG using a random seed, height 40, and width 40. */ public SectionDungeonGenerator() { rng = new StatefulRNG(); utility = new DungeonUtility(rng); rebuildSeed = rng.getState(); height = 40; width = 40; roomFX = new EnumMap<>(FillEffect.class); corridorFX = new EnumMap<>(FillEffect.class); caveFX = new EnumMap<>(FillEffect.class); }
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; }
@Override public String stringify(StatefulRNG item) { return StringKit.hex(item.getState()) + ':' + (item.getRandomness().getClass().getSimpleName()); }
rng.setState(seed); factionCount = Math.abs(factionCount % 254); Thesaurus th = new Thesaurus(rng.nextLong()); th.addKnownCategories(); ArrayList<Faction> fact = factions == null ? new ArrayList<Faction>() : rng.shuffle(factions); for (int i = fact.size(); i < factionCount; i++) { String name = th.makeNationName(), shortName = th.latestGenerated; rng.shuffleInPlace(fact); fact.add(0, new Faction(FakeLanguageGen.DEMONIC, "The Lost Wilderness", "Wilderness")); fact.add(0, new Faction(FakeLanguageGen.ALIEN_O, "The Vast Domain of the Seafolk", "Seafolk", new String[]{"Ocean"})); hot = biomeMapper.getHeatCode(cx, cy); moist = biomeMapper.getMoistureCode(cx, cy); rng.randomOrdering(count, reorder); PER_FACTION: for (int i = 0; i < count; i++) { cy = cen / width; politicalMap[cx][cy] = keys[i] = atlas.keyAt(factionIndices[i] + 2); biases[i] = rng.nextDouble() * rng.nextDouble() + rng.nextDouble() + 0.03125; hasFresh = true; else hasFresh = true; if (rng.nextDouble() < biases[i]) { int index = rng.nextIntHasty(currentFresh.size), cell = currentFresh.get(index); cx = cell % width; cy = cell / width;
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; eLen = entries.size(); for (int j = 0; j < 32; j++) { entries.put(tmpInner.singleRandom(rng), (rng.nextDouble() + 1.5) * 0.4); Coord[] centers = map.mixedRandomSeparated(0.1, factionCount, rng.nextLong()); int controlled = (int) (map.size() * Math.max(0.0, Math.min(1.0, controlledFraction))); 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)); atlas.put('%', "Wilderness"); if(factionCount > 0) { Thesaurus th = new Thesaurus(rng.nextLong()); th.addKnownCategories(); for (int i = 0; i < factionCount && i < 256; i++) { 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); g2 = new GreasedRegion(width, height).insertSeveral(peaks).expand(4).deteriorate(rng, 2).and(m2); groups.add(g2);
if(!seedFixed) rebuildSeed = rng.getState();
sizeWaterPools = targetWater / rng.between(3, 6), sizeGrassPools = targetGrass / rng.between(2, 5); if(targetWater > 0) { scatter = floors.quasiRandomSeparated(1.0 / 7.0); rng.shuffleInPlace(scatter); GreasedRegion allWater = new GreasedRegion(width, height); for (int i = 0; i < scatter.length; i++) { working.empty().insert(scatter[i]).spill(floors, rng.between(4, Math.min(remainingWater, sizeWaterPools)), rng); rng.shuffleInPlace(scatter); for (int i = 0; i < scatter.length; i++) { 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; Coord entry = rng.getRandomElement(hazards); if(map[entry.x][entry.y] == '<' || map[entry.x][entry.y] == '<') continue;
d = Direction.CLOCKWISE[i]; summon(delay, x, y, x - d.deltaX * distance, y + d.deltaY * distance, choices.charAt(rng.nextIntHasty(len)), startColor, endColor, duration, null); choices.charAt(rng.nextIntHasty(len)), startColor, endColor, duration, postRunnable); summon(delay, xf, yf, xf - d.deltaX * font.actualCellWidth * distance * 0.7071067811865475f, yf + d.deltaY * font.actualCellHeight * distance * 0.7071067811865475f, choices.charAt(rng.nextIntHasty(len)), startColor, endColor, duration, null); d = Direction.CARDINALS_CLOCKWISE[i]; summon(delay, x, y, x - d.deltaX * distance, y + d.deltaY * distance, choices.charAt(rng.nextIntHasty(len)), startColor, endColor, duration, null); choices.charAt(rng.nextIntHasty(len)), startColor, endColor, duration, postRunnable);
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; DeckRNG deckRNG = (DeckRNG) o; return step == deckRNG.step && lastShuffledState == deckRNG.lastShuffledState; }
@Override public int hashCode() { int result = super.hashCode() * 31; result += NumberTools.doubleToMixedIntBits(expected); result = 31 * result + NumberTools.doubleToMixedIntBits(centrality); return result; }
Coord entry = rng.getRandomElement(doorways); if (map[entry.x][entry.y] == '<' || map[entry.x][entry.y] == '>') continue;
rebuildSeed = rng.getState();
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; EditRNG editRNG = (EditRNG) o; if (Double.compare(editRNG.expected, expected) != 0) return false; return Double.compare(editRNG.centrality, centrality) == 0; }
/** * Constructs a FantasyPoliticalMapper, but doesn't do anything with a map; you need to call * {@link #generate(long, WorldMapGenerator, WorldMapGenerator.BiomeMapper, Collection, int, double)} for results. */ public FantasyPoliticalMapper() { rng = new StatefulRNG(); }
/** * Copies all fields from copying and makes a new DungeonGenerator. * @param copying the DungeonGenerator to copy */ public SectionDungeonGenerator(SectionDungeonGenerator copying) { rng = new StatefulRNG(copying.rng.getState()); utility = new DungeonUtility(rng); rebuildSeed = rng.getState(); height = copying.height; width = copying.width; Coord.expandPoolTo(width, height); roomFX = new EnumMap<>(copying.roomFX); corridorFX = new EnumMap<>(copying.corridorFX); caveFX = new EnumMap<>(copying.caveFX); doorFX = copying.doorFX; lakeFX = copying.lakeFX; deepLakeGlyph = copying.deepLakeGlyph; shallowLakeGlyph = copying.shallowLakeGlyph; dungeon = copying.dungeon; }
rebuildSeed = rng.getState(); environmentType = kind.environment(); DungeonBoneGen gen = new DungeonBoneGen(rng);
/** * 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); } /**