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

Function prune_specks

map.py:464–482  ·  view source on GitHub ↗
(cfg: Config, mask: np.ndarray, tag: str, passes: int, kill_prob: float = 0.70)

Source from the content-addressed store, hash-verified

462
463
464def prune_specks(cfg: Config, mask: np.ndarray, tag: str, passes: int, kill_prob: float = 0.70) -> np.ndarray:
465 out = mask.copy()
466 rows, cols = out.shape
467 for _ in range(max(0, int(passes))):
468 kill = []
469 for r in range(rows):
470 for c in range(cols):
471 if not out[r, c]:
472 continue
473 n = neighbor_count(out, r, c)
474 if n == 0:
475 kill.append((r, c))
476 elif n == 1 and hash01(cfg.seed, r, c, tag) < kill_prob:
477 kill.append((r, c))
478 if not kill:
479 break
480 for r, c in kill:
481 out[r, c] = False
482 return out
483
484
485def thin_mountains(cfg: Config, mtn: np.ndarray, ridges: np.ndarray) -> np.ndarray:

Callers 1

thin_mountainsFunction · 0.85

Calls 2

neighbor_countFunction · 0.85
hash01Function · 0.85

Tested by

no test coverage detected