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

Function build_fields

map.py:507–545  ·  view source on GitHub ↗
(cfg: Config)

Source from the content-addressed store, hash-verified

505
506
507def build_fields(cfg: Config):
508 shape = (cfg.rows, cfg.cols)
509
510 cont = noise_field(cfg, 10, cfg.continental_scale, cfg.continental_octaves, cfg.continental_smooth_passes)
511 cont = np.clip((cont - 0.22) / 0.78, 0.0, 1.0).astype(np.float32)
512
513 peaks = ridged01(normalize01(fbm(shape, cfg.seed + 20, cfg.peaks_scale, cfg.peaks_octaves, cfg.persistence, cfg.lacunarity)))
514 erosion = noise_field(cfg, 30, cfg.erosion_scale, cfg.erosion_octaves, 0)
515
516 ridge_a = fbm_aniso(shape, cfg.seed + 25, cfg.ridge_scale_short, cfg.ridge_scale_long, cfg.ridge_octaves, cfg.persistence, cfg.lacunarity)
517 ridge_b = fbm_aniso(shape, cfg.seed + 26, cfg.ridge_scale_long, cfg.ridge_scale_short, cfg.ridge_octaves, cfg.persistence, cfg.lacunarity)
518 ridges = smooth_box(np.maximum(ridged01(normalize01(ridge_a)), ridged01(normalize01(ridge_b))), 1)
519
520 humid0 = noise_field(cfg, 40, cfg.humid_scale, cfg.humid_octaves, 0)
521 temp0 = noise_field(cfg, 50, cfg.temp_scale, cfg.temp_octaves, 0)
522
523 wx = ((noise_field(cfg, 71, cfg.warp_scale, cfg.warp_octaves, 0) - 0.5) * 2.0 * cfg.warp_amp).astype(np.int32)
524 wy = ((noise_field(cfg, 72, cfg.warp_scale, cfg.warp_octaves, 0) - 0.5) * 2.0 * cfg.warp_amp).astype(np.int32)
525 humid = warp_int(humid0, wx, wy)
526 temp_noise = warp_int(temp0, -wx, wy)
527
528 peaks2 = peaks * (1.0 - cfg.erosion_strength * erosion)
529 elev = normalize01(cont + cfg.peaks_strength * peaks2 + cfg.ridge_strength * ridges)
530
531 lat = np.linspace(0.0, 1.0, cfg.rows, dtype=np.float32)
532 equator = 1.0 - np.abs(lat * 2.0 - 1.0)
533
534 temp = 0.70 * equator[:, None] + 0.30 * temp_noise
535 temp = temp - 0.38 * np.clip(elev - cfg.sea_level, 0.0, 1.0)
536 temp = normalize01(temp)
537
538 land = elev >= cfg.sea_level
539 dist_to_land = hex_bfs_distance(land)
540 dist_to_water = hex_bfs_distance(~land)
541
542 water_influence = np.exp(-dist_to_water.astype(np.float32) / 3.2).astype(np.float32)
543 humid2 = normalize01(0.70 * humid + 0.30 * water_influence)
544
545 return elev, peaks, ridges, humid2, temp, equator, land, dist_to_land, dist_to_water
546
547
548def build_mountains(cfg: Config, land: np.ndarray, elev: np.ndarray, peaks: np.ndarray, ridges: np.ndarray, temp: np.ndarray) -> np.ndarray:

Callers 1

build_tilemapFunction · 0.85

Calls 8

noise_fieldFunction · 0.85
ridged01Function · 0.85
normalize01Function · 0.85
fbmFunction · 0.85
fbm_anisoFunction · 0.85
smooth_boxFunction · 0.85
warp_intFunction · 0.85
hex_bfs_distanceFunction · 0.85

Tested by

no test coverage detected