MCPcopy Create free account
hub / github.com/Astropulse/hexmap / build_mountains

Function build_mountains

map.py:548–566  ·  view source on GitHub ↗
(cfg: Config, land: np.ndarray, elev: np.ndarray, peaks: np.ndarray, ridges: np.ndarray, temp: np.ndarray)

Source from the content-addressed store, hash-verified

546
547
548def build_mountains(cfg: Config, land: np.ndarray, elev: np.ndarray, peaks: np.ndarray, ridges: np.ndarray, temp: np.ndarray) -> np.ndarray:
549 warm = temp > cfg.cold_temp
550 ridge_zone = land & warm & (elev >= (cfg.mountain_level - 0.06)) & (ridges >= cfg.ridge_mountain_thresh)
551 rr = np.clip((ridges - cfg.ridge_mountain_thresh) / max(1e-6, 1.0 - cfg.ridge_mountain_thresh), 0.0, 1.0)
552 keep_prob = np.clip(cfg.mountain_ridge_keep_base + cfg.mountain_ridge_keep_gain * rr, 0.0, 1.0)
553
554 mtn = np.zeros_like(land, dtype=bool)
555 ys, xs = np.where(ridge_zone)
556 for r, c in zip(ys.tolist(), xs.tolist()):
557 if hash01(cfg.seed, r, c, "mtn_ridge") < float(keep_prob[r, c]):
558 mtn[r, c] = True
559
560 peak_zone = land & warm & (elev >= cfg.mountain_level) & (peaks >= cfg.peak_mountain_thresh)
561 ys, xs = np.where(peak_zone & (~mtn))
562 for r, c in zip(ys.tolist(), xs.tolist()):
563 if hash01(cfg.seed, r, c, "mtn_peak") < cfg.mountain_peak_keep_prob:
564 mtn[r, c] = True
565
566 return thin_mountains(cfg, mtn, ridges)
567
568
569def add_lakes(cfg: Config, elev: np.ndarray, land: np.ndarray, dist_to_water: np.ndarray, dist_to_mtn: np.ndarray):

Callers 1

build_tilemapFunction · 0.85

Calls 2

hash01Function · 0.85
thin_mountainsFunction · 0.85

Tested by

no test coverage detected