not good but not bad

This commit is contained in:
33333-33333 2026-05-26 15:32:27 +09:00
commit 4f0df3f6c5
11 changed files with 1284 additions and 622 deletions

View file

@ -44,6 +44,7 @@ export function generateMapFeatures(seed, terrain) {
const i = indexOf(x, y);
if (sea[i]) return -1;
if (prefectureMask?.[i]) return 0;
if (!prefectureRegionId) return 0;
const id = prefectureRegionId?.[i];
return id !== undefined && id >= 0 ? id : -1;
}
@ -704,6 +705,11 @@ export function generateMapFeatures(seed, terrain) {
function addKernel(grid, p, radius, weight, exponent = 1.7, terrainWeighted = true, combine = "max") {
const r = Math.ceil(radius);
const angle = hash2(p.x, p.y, seed + 14901) * Math.PI * 2;
const stretch = 1.35 + hash2(p.x, p.y, seed + 14902) * 0.85;
const squeeze = 0.62 + hash2(p.x, p.y, seed + 14903) * 0.28;
const ca = Math.cos(angle);
const sa = Math.sin(angle);
for (let dy = -r; dy <= r; dy++) {
for (let dx = -r; dx <= r; dx++) {
const x = p.x + dx;
@ -711,9 +717,28 @@ export function generateMapFeatures(seed, terrain) {
if (!inside(x, y)) continue;
const i = indexOf(x, y);
if (sea[i]) continue;
const d = Math.hypot(dx, dy);
const along = (dx * ca + dy * sa) / stretch;
const across = (-dx * sa + dy * ca) / squeeze;
const baseD = Math.hypot(along, across);
const conduit = clamp(
plain[i] * 0.18 +
valleySettlement[i] * 0.26 +
coastalSettlement[i] * 0.16 +
roadDensityInfluence[i] * 0.34 +
roadInfluence[i] * 0.22 +
railInfluence2[i] * 0.26 +
stationDensityInfluence[i] * 0.12
);
const barrier = clamp(
slope[i] * 0.62 +
ridgeField[i] * 0.74 +
Math.max(0, elevation[i] - 0.58) * 0.82 +
(river[i] > 0.68 ? 0.60 : river[i] > 0.34 ? 0.22 : 0)
);
const noise = 0.78 + hash2(x, y, seed + 14910 + Math.round((p.population || 0) / 1000)) * 0.46;
const d = baseD * (1.10 - conduit * 0.42 + barrier * 0.62) * noise;
if (d > radius) continue;
const terrain = terrainWeighted ? clamp(0.24 + developable[i] * 1.00 + valleySettlement[i] * 0.16 + coastalSettlement[i] * 0.10 - slope[i] * 0.20 - ridgeField[i] * 0.12 + roadInfluence[i] * 0.08 + roadDensityInfluence[i] * 0.04 + railInfluence2[i] * 0.06, 0, 1.34) : 1;
const terrain = terrainWeighted ? clamp(0.06 + developable[i] * 1.08 + valleySettlement[i] * 0.24 + coastalSettlement[i] * 0.14 + conduit * 0.38 - barrier * 0.70, 0, 1.42) : 1;
const v = weight * Math.pow(1 - d / Math.max(1, radius), exponent) * terrain;
if (combine === "add") grid[i] = Math.min(3.4, grid[i] + v);
else if (v > grid[i]) grid[i] = v;
@ -807,7 +832,8 @@ export function generateMapFeatures(seed, terrain) {
ridgeField[i] * 0.020 -
highPenaltyDensity * 0.058
);
ruralDensityFloor[i] = clamp(0.010 + agrarianDensity, 0, elevation[i] > 0.62 || slope[i] > 0.42 ? 0.052 : 0.115);
const remoteWilderness = elevation[i] > 0.60 && slope[i] > 0.34 && ridgeField[i] > 0.38 && densityTransport < 0.035 && villageInfluence[i] < 0.025 && townInfluence[i] < 0.025 && cityInfluence[i] < 0.025;
ruralDensityFloor[i] = remoteWilderness ? 0 : clamp(agrarianDensity, 0, elevation[i] > 0.62 || slope[i] > 0.42 ? 0.052 : 0.105);
populationDensity[i] = clamp(
urban * 0.66 +
core * 0.46 +
@ -900,9 +926,11 @@ export function generateMapFeatures(seed, terrain) {
} else if (lu === LANDUSE.RURAL) {
floor = Math.max(floor, clamp(0.012 + ruralSuitability[i] * 0.020 + developable[i] * 0.014 + roadDensityInfluence[i] * 0.024 + stationDensityInfluence[i] * 0.020, 0, 0.070));
} else if (lu === LANDUSE.FOREST) {
floor = Math.min(floor, 0.032);
floor = Math.min(floor, (roadDensityInfluence[i] > 0.04 || villageInfluence[i] > 0.03) ? 0.026 : 0);
}
populationDensity[i] = clamp(Math.max(populationDensity[i] / maxDensity, floor));
const normalized = populationDensity[i] / maxDensity;
populationDensity[i] = clamp(Math.max(normalized, floor));
if (lu === LANDUSE.FOREST && floor === 0 && populationDensity[i] < 0.012) populationDensity[i] = 0;
}
}
}