Fauna habitat probe kept as research; option images; lattice verdict (B25g, B25h)
Moves the closed-form habitat probe scripts and the images each habitat question option names into docs/research/2026-10-14-fauna-habitat-probe/, points the map there, and adds the option renders under the spec's law and the probe that shows the convergence lattice is FlowField's own structure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e760333baf
commit
417dd6c94a
26 changed files with 529 additions and 3 deletions
|
|
@ -319,13 +319,15 @@ the closed form: `docs/research/2026-10-14-fauna-placement-closed-form.md` (`CF:
|
|||
| # | Question | Result |
|
||||
|---|---|---|
|
||||
| B24 | Does the gravity field move? | Yes, in closed form of zone time. Orbit positions are `OrbitData.Evaluate(frac(_time / Period + Phase)) * Distance` plus the parent's position, cached per tick (`Zone.cs:476-497`). `GetHeight` subtracts each gas giant's `RadialWaves(..., _time * speed)` (`Zone.cs:645-655`), and `Sun` derives from `GasGiant` (`Zone.cs:771`), so the sun's well ripples too; `GasGiantData` defaults give wave speed x8 (`ZoneData.cs:199`). The slope at a point is a function of `_time`, and nothing in `GetHeight` can be evaluated at another time without a time parameter. |
|
||||
| B25 | Which pointwise closed form makes the slime look? (scratch probe, not committed) | A pure-Python transliteration of `FlowField.Global`/`Slope`/`Scroll` at `5f5a1e4d` and `Zone.GetHeight`/`GetNormal`/`PowerPulse`/`RadialWaves` at `b836af48`, on the B20 zone (sun, four planets, a gas giant; radius 2000; live flow scale 512, amplitude 15, scroll speed .025), 256² grid at t = 100 s, float64 (C# is float32). Density images were written per candidate, member-dot images under fixed per-candidate thresholds (jittered 16 u lattice, about 49k candidates), and correlated with the B20 Physarum maps (64x32 blocks). Results follow in the next rows. Script and images: Self's scratch for session self-2026-10-14-ag, `imagination-aeth-fauna-r3/` (`habitat_probe.py`, `density_*.png`, `members_*.png`). |
|
||||
| B25 | Which pointwise closed form makes the slime look? (scratch probe, not committed) | A pure-Python transliteration of `FlowField.Global`/`Slope`/`Scroll` at `5f5a1e4d` and `Zone.GetHeight`/`GetNormal`/`PowerPulse`/`RadialWaves` at `b836af48`, on the B20 zone (sun, four planets, a gas giant; radius 2000; live flow scale 512, amplitude 15, scroll speed .025), 256² grid at t = 100 s, float64 (C# is float32). Density images were written per candidate, member-dot images under fixed per-candidate thresholds (jittered 16 u lattice, about 49k candidates), and correlated with the B20 Physarum maps (64x32 blocks). Results follow in the next rows. Scripts, images and how to rerun: `docs/research/2026-10-14-fauna-habitat-probe/` (README there). These rows' member counts normalise density by its zone maximum, which the law may not do (CF:56); B25g gives the counts under the spec's law. The first `members_c6_band_soft_windrows_swirl.png` was a mislabelled render and is not kept. |
|
||||
| B25a | Slope band alone (`c0`: the operator's `Deposition(slope)`, zero past slope .8) | Rings on every planet's shoulder, a bright bridge where two shoulders meet; correlation with Physarum A .517 (B .483), the highest of all candidates. 1,435 members. Changes 3.3 % of members in 1 s and 20 % in 8 s from the wells' ripples alone (B24). |
|
||||
| B25b | Band times flow convergence (`c1`, gain 3; `c6`, gain 1.5, slope terms on: swirl 6, slide 1.5) | Langmuir-windrow analogue (CF:17-18). The band keeps its rings, cut by the flow's convergence into a crisp triangular texture: `Tri3D` is piecewise linear (`tri`), so its derivatives are piecewise constant and the convergence field is a tiling of hard-edged triangles and diagonal streaks. `c6` correlation .464 (B .449); `c1` .428. Members gather in clumps on the shoulders with thin lines between wells. Under continuous evaluation 20-22 % of members change in 1 s and 89-94 % in 8 s: the flow scrolls a full first-octave phase in 40 s (1 / .025). Convergence std over the zone is .147 /s live and .151 /s with the slope terms on. |
|
||||
| B25c | Band times flow-along-contour (`c5`, narrow; `c7`, wide) | Members where the flow runs along the well's contour (neither climbing nor falling). Fine scalloped arcs, more organic than `c6`, but sparse (94 members narrow, 395 wide) and unstable: 42-134 % of members change in 1 s. `c7` correlation .480. |
|
||||
| B25d | Okubo-Weiss strain (`c2`) and gravity saddles (`c3`, `c4`) | `c2` (band times sigmoid of W, CF:11) correlation .507, texture like `c1`. `c3` (negative Hessian determinant of the height: outer shoulders and saddles between wells) makes clean rings with dark gaps and no links, .377. `c4` (`c3` times convergence) .316. |
|
||||
| B25e | Does a presence fade on the density stop pops? (`pop_probe.py`) | No. `c6` with a fade band of .1 around each threshold, 600 shoulder candidates, 180 steps of 1/60 s from t = 100: the density moves by up to .267 in one step, so presence moves by up to .35 in one step (4 steps over .25; .56 with a band of .05). The same with the slope terms off, so the jumps are the global `Tri3D` term's: its convergence changes almost discontinuously in time at some points. |
|
||||
| B25f | Does reading the flow term at the member's own cycle start stop them? (`pop_cycle.py`) | Yes. Band at now, convergence at the member's cycle start (period 8 s, hashed phase), same fade and candidates: presence moves by at most .0003 per step within a cycle, 0 steps over .25; the flow term changes only at the 221 cycle turns, where `fauna-flow-coupling-ruled` already fades the member. The slope band moves smoothly (B24's ripples are continuous). `FlowField.At` takes a scroll, and `FlowField.Scroll(settings, t)` is pure in t, so the flow at a past zone time needs no new owner. |
|
||||
| B25e | Does a presence fade on the density stop pops? (`docs/research/2026-10-14-fauna-habitat-probe/pop_probe.py`) | No. `c6` with a fade band of .1 around each threshold, 600 shoulder candidates, 180 steps of 1/60 s from t = 100: the density moves by up to .267 in one step, so presence moves by up to .35 in one step (4 steps over .25; .56 with a band of .05). The same with the slope terms off, so the jumps are the global `Tri3D` term's: its convergence changes almost discontinuously in time at some points. |
|
||||
| B25f | Does reading the flow term at the member's own cycle start stop them? (`docs/research/2026-10-14-fauna-habitat-probe/pop_cycle.py`) | Yes. Band at now, convergence at the member's cycle start (period 8 s, hashed phase), same fade and candidates: presence moves by at most .0003 per step within a cycle, 0 steps over .25; the flow term changes only at the 221 cycle turns, where `fauna-flow-coupling-ruled` already fades the member. The slope band moves smoothly (B24's ripples are continuous). `FlowField.At` takes a scroll, and `FlowField.Scroll(settings, t)` is pure in t, so the flow at a past zone time needs no new owner. |
|
||||
| B25g | The options under the spec's law (`habitat_options.py`, `pop_maps.py`) | Absolute density, fixed constants of `cut-fauna-habitat-placement.r1`, candidate thresholds .1 + .9h, fade .1, slope terms on, 49,083 candidates at 16 u. Hosted at t = 100 and changed under continuous evaluation in 1 s / 8 s: band-only 4,388, 2.0 % / 12.2 %; band-times-convergence 2,235, 10.3 % / 47.1 %; band-times-strain 2,721, 7.9 % / 31.3 %; band-times-contour-flow 2,307, 15.8 % / 49.2 %. No-pop, convergence law, 5,607 shoulder candidates, 60 steps of 1/60 s, largest presence step with cycle turns excluded and members moving > .1 in a step: presence-fade .33, 2 members; cycle-sampled-flow .0010, 0; cycle-sampled-all .0000, 0. Images: `option_density_<option>.png`, `option_members_<option>.png`, `option_nopop_<option>.png`. |
|
||||
| B25h | Is the triangular lattice in the convergence the law's or the probe's? (`lattice_probe.py`) | The law's. Along a 2,048 u transect at 0.5 u spacing, all 40 of the 40 largest convergence jumps lie within 1 u of a kink line predicted from `tri`'s arguments in `FlowField.Tri3D` (both octaves; 53 lines cross the transect). The derivative step does not make it: convergence with step 6 and step .5 correlates .964. Rounding the inputs to float32 moves the flow by at most 5.6e-9 u/s (arithmetic stays float64, so this bounds input rounding only). The shader never renders the flow's derivative; it advects nebula noise and stardust by the flow's value, which is continuous, so the lattice is not visible in game today. A density driven by convergence would carry it into member placement: crisp in a density render, a soft patchiness at the member density of `option_members_band-times-convergence.png`. |
|
||||
| B26 | Is Sol a zone the code can tell apart? | No. No `ServerShared` code names Sol (grep of `Sol\b` outside `Solar`/`Solid`/`Solve`); a zone's seed is `GalaxyZone.Name.StableHash()` (`Zone.cs:144`, `CombatSeed`). `fauna-none-in-sol` needs the per-zone environment of `sol-flatspace-zone`. |
|
||||
| B27 | Is there placement code to cut? | No. Nothing under `Assets/Scripts/ServerShared` or `tests/Aetheria.Shared.Tests` names habitat or fauna at `b836af48`. The generation pass of r2 was never built. |
|
||||
|
||||
|
|
|
|||
6
docs/research/2026-10-14-fauna-habitat-probe/README.md
Normal file
6
docs/research/2026-10-14-fauna-habitat-probe/README.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Fauna habitat probe (2026-10-14)
|
||||
|
||||
Serves ruling `aetheria-fauna:ruling:fauna-placement-ruled` and the questions `aetheria-fauna:question:habitat-density-driver` and `:habitat-no-pop`, raised in `cut-fauna-habitat-placement.r1`. Facts are map rows B25-B25h in `docs/aetheria-fauna-map.md`.
|
||||
`habitat_probe.py` is a pure-Python, float64 transliteration of `FlowField` (branch `eureka/aetheria-fauna-flow-field` at `5f5a1e4d`) and `Zone.GetHeight`/`GetNormal` (`b836af48`) on the B20 zone. It is not the C# law, which is float32; the images are qualitative evidence, and the numbers are the transliteration's.
|
||||
Images: `option_density_*` and `option_members_*` (one per density-driver option, spec r1 constants, slope terms on), `option_nopop_*` (one per no-pop option; red = a member that popped), and the earlier `density_c*` and `members_c0` renders (normalised per image).
|
||||
To rerun, copy this folder to a scratch directory (the scripts write PNGs next to themselves), then `py -3 habitat_options.py`, `py -3 pop_maps.py`, `py -3 lattice_probe.py`, `py -3 pop_probe.py` (env FADE), `py -3 pop_cycle.py`, or `py -3 habitat_probe.py 256 live|swirl <candidates> <member candidates>`. Python 3 only, no packages; each takes 1-5 minutes.
|
||||
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c0_slope_band_live.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c0_slope_band_live.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c1_windrows_live.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c1_windrows_live.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c2_strain_live.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c2_strain_live.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c5_contour_currents_swirl.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c5_contour_currents_swirl.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c6_band_soft_windrows_swirl.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c6_band_soft_windrows_swirl.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c7_band_wide_contour_swirl.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/density_c7_band_wide_contour_swirl.png
(Stored with Git LFS)
Normal file
Binary file not shown.
|
|
@ -0,0 +1,69 @@
|
|||
"""Density and member images per option of aetheria-fauna:question:habitat-density-driver, under the spec's law
|
||||
(cut-fauna-habitat-placement.r1): absolute density in [0, 1], fixed constants (no zone-wide normalisation),
|
||||
candidate threshold .1 + .9 h, presence = smoothstep(thr - .1, thr + .1, density), hosted = presence > 0.
|
||||
Slope terms on (swirl 6, slide 1.5: flow-slope-terms-ruled turns them on). Uses habitat_probe.py's transliteration.
|
||||
"""
|
||||
import math, os, sys, zlib, struct
|
||||
sys.argv = sys.argv[:1]
|
||||
import habitat_probe as H
|
||||
|
||||
H.FLOW.update(swirl=6.0, slope=1.5)
|
||||
OUT = H.OUT; R = H.R; T = 100.0
|
||||
|
||||
|
||||
def band(s): return H.deposition(s) / 2
|
||||
|
||||
|
||||
OPTIONS = { # option label -> density of the locals (s, div, W, det, a)
|
||||
"band-only": lambda s, div, W, det, a: band(s),
|
||||
"band-times-convergence": lambda s, div, W, det, a: band(s) * H.sig(1.5 * -div / .15),
|
||||
"band-times-strain": lambda s, div, W, det, a: band(s) * H.sig(3 * W / .086),
|
||||
"band-times-contour-flow": lambda s, div, W, det, a: band(s) * (.25 + .75 * math.exp(-(a / .45) ** 2)),
|
||||
}
|
||||
|
||||
|
||||
def read_png(path):
|
||||
d = open(path, "rb").read(); i = 8; idat = b""; w = h = 0
|
||||
while i < len(d):
|
||||
n = struct.unpack(">I", d[i:i + 4])[0]; t = d[i + 4:i + 8]; c = d[i + 8:i + 8 + n]
|
||||
if t == b"IHDR": w, h = struct.unpack(">II", c[:8])
|
||||
if t == b"IDAT": idat += c
|
||||
i += 12 + n
|
||||
return zlib.decompress(idat)
|
||||
|
||||
|
||||
old1 = os.path.join(OUT, "members_c1_windrows.png"); old6 = os.path.join(OUT, "members_c6_band_soft_windrows_swirl.png")
|
||||
if os.path.exists(old1) and os.path.exists(old6):
|
||||
print(f"old members_c1 vs old members_c6_swirl: bytes identical = {read_png(old1) == read_png(old6)}")
|
||||
|
||||
# densities on a 256 grid
|
||||
G = 256; grid = []
|
||||
sc = H.scroll(T)
|
||||
for j in range(G):
|
||||
for i in range(G):
|
||||
x = ((i + .5) / G - .5) * 2 * R; z = ((j + .5) / G - .5) * 2 * R
|
||||
grid.append(None if x * x + z * z > R * R else H.locals_at(x, z, T, sc))
|
||||
for name, f in OPTIONS.items():
|
||||
px = [(0, 0, 0) if v is None else H.ramp(f(*v)) for v in grid] # absolute [0, 1] scale, same for all options
|
||||
H.mark_bodies(px, G); p = os.path.join(OUT, f"option_density_{name}.png"); H.write_png(p, G, G, px); print("png", p)
|
||||
|
||||
# members: 16 u jittered lattice, evaluated at T, T+1, T+8
|
||||
C = 16.0; n = int(2 * R / C); cands = []
|
||||
for j in range(n):
|
||||
for i in range(n):
|
||||
x = (i + H.hash01(i, j, 1)) * C - R; z = (j + H.hash01(i, j, 2)) * C - R
|
||||
if x * x + z * z <= R * R: cands.append((i, j, x, z, .1 + .9 * H.hash01(i, j, 3)))
|
||||
loc = {}
|
||||
for tt in (T, T + 1.0, T + 8.0):
|
||||
s2 = H.scroll(tt); loc[tt] = [H.locals_at(x, z, tt, s2) for (_, _, x, z, _) in cands]
|
||||
for name, f in OPTIONS.items():
|
||||
pres = {tt: [H.smoothstep(c[4] - .1, c[4] + .1, f(*v)) for c, v in zip(cands, loc[tt])] for tt in loc}
|
||||
hosted = {tt: {k for k, p in enumerate(pres[tt]) if p > 0} for tt in pres}
|
||||
a = hosted[T]
|
||||
print(f"{name}: {len(a)} hosted of {len(cands)} candidates; changed in 1 s {len(a ^ hosted[T + 1]) / max(1, len(a)):.3f}, in 8 s {len(a ^ hosted[T + 8]) / max(1, len(a)):.3f} (continuous evaluation)")
|
||||
W2 = 600; px = [(10, 14, 30)] * (W2 * W2)
|
||||
for k in a:
|
||||
_, _, x, z, _ = cands[k]; b = pres[T][k]
|
||||
pi_, pj = int((x / (2 * R) + .5) * W2), int((z / (2 * R) + .5) * W2)
|
||||
if 0 <= pi_ < W2 and 0 <= pj < W2: px[pj * W2 + pi_] = tuple(int(30 + (c - 30) * b) for c in (235, 230, 170))
|
||||
H.mark_bodies(px, W2); p = os.path.join(OUT, f"option_members_{name}.png"); H.write_png(p, W2, W2, px); print("png", p)
|
||||
211
docs/research/2026-10-14-fauna-habitat-probe/habitat_probe.py
Normal file
211
docs/research/2026-10-14-fauna-habitat-probe/habitat_probe.py
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
"""Habitat closed-form probe (Imagination, aetheria-fauna r3). Pure Python, no deps.
|
||||
|
||||
Transliterates, term for term:
|
||||
- FlowField.Global / Slope / Scroll (branch eureka/aetheria-fauna-flow-field @ 5f5a1e4d, FlowField.cs)
|
||||
- Zone.GetHeight / GetNormal / PowerPulse / RadialWaves (b836af48, Zone.cs:631-720)
|
||||
- the earlier probe's zone: same bodies, same PlanetSettings values (2026-10-13 probe)
|
||||
Evaluates candidate pointwise habitat densities over the zone, writes a PNG per candidate, member-dot PNGs
|
||||
under the fixed-threshold (HZD dither) placement, and turnover numbers. Float64 here; C# is float32.
|
||||
"""
|
||||
import math, struct, zlib, sys, os, time
|
||||
|
||||
OUT = os.path.dirname(os.path.abspath(__file__))
|
||||
R = 2000.0
|
||||
G = int(sys.argv[1]) if len(sys.argv) > 1 else 200
|
||||
GOLD = 1.61803398875
|
||||
|
||||
# --- PlanetSettings (earlier probe = Settings.asset values) ---
|
||||
def curve(m, e, mul, c=0.0): return mul * m ** e + c
|
||||
BODIES = [("Sun", 14152, 0, 0), ("Planet", 274, 610, .4), ("Planet", 274, 1050, 2.6),
|
||||
("GasGiant", 2260, 1400, 4.4), ("Planet", 120, 1700, 4.6), ("Planet", 29, 450, 3.9)]
|
||||
WELLS = []
|
||||
for kind, m, d, ph in BODIES:
|
||||
pos = (math.cos(ph) * d, math.sin(ph) * d)
|
||||
w = dict(pos=pos, r=curve(m, .25, 500), depth=curve(m, .175, 30), exp=16.0, gas=kind in ("Sun", "GasGiant"))
|
||||
if w["gas"]: # Sun : GasGiant; GasGiantData defaults: radius x1, depth x1, speed x8
|
||||
w.update(wr=curve(m, .25, 500), wd=curve(m, .3, .5), wf=curve(m, .45, .2), ws=.025 * 8)
|
||||
WELLS.append(w)
|
||||
|
||||
def pp(x, e):
|
||||
x *= 2; x = max(-1.0, min(1.0, x)); return ((x + 1) * (1 - x)) ** e
|
||||
|
||||
def height(x, z, t):
|
||||
h = -pp(math.hypot(x, z) / (R * 2), 2) * 64
|
||||
for w in WELLS:
|
||||
dx, dz = x - w["pos"][0], z - w["pos"][1]
|
||||
d2 = dx * dx + dz * dz
|
||||
if d2 < w["r"] ** 2: h -= pp(math.sqrt(d2) / w["r"], w["exp"]) * w["depth"]
|
||||
if w["gas"] and d2 < w["wr"] ** 2:
|
||||
u = math.sqrt(d2) / w["wr"]
|
||||
h -= pp(u, 8) * math.cos((u * 2) ** 1.25 * w["wf"] + t * w["ws"]) * w["wd"]
|
||||
return h
|
||||
|
||||
def normal(x, z, t, step=.1):
|
||||
a = height(x - step, z, t) - height(x + step, z, t)
|
||||
b = height(x, z - step, t) - height(x, z + step, t)
|
||||
n = math.sqrt(a * a + b * b + (2 * step) ** 2)
|
||||
return a / n, 2 * step / n, b / n # .xzy: (x, y=up, z)
|
||||
|
||||
# --- FlowField (5f5a1e4d) ---
|
||||
FLOW = dict(scale=512.0, amp=15.0, speed=.025, slope=0.0, swirl=0.0)
|
||||
def frac(v): return v - math.floor(v)
|
||||
def tri(v): return abs(frac(v) - .5)
|
||||
def tri3(p): return (tri(p[2] + tri(p[1])), tri(p[2] + tri(p[0])), tri(p[1] + tri(p[0])))
|
||||
def nrm(v):
|
||||
l = math.sqrt(v[0] ** 2 + v[1] ** 2 + v[2] ** 2); return (v[0] / l, v[1] / l, v[2] / l)
|
||||
def scroll(t): s = FLOW["speed"] * t; return frac(s), frac(s * GOLD)
|
||||
def flow_global(x, y, z, sc):
|
||||
f = (x / FLOW["scale"], y / FLOW["scale"], z / FLOW["scale"])
|
||||
a = nrm(tri3((f[0], f[1] - sc[0], f[2])))
|
||||
b = nrm(tri3((f[0] * GOLD, f[1] * GOLD - sc[1], f[2] * GOLD)))
|
||||
c = (a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0])
|
||||
A = FLOW["amp"]; return c[0] * A, c[1] * A * .5, c[2] * A
|
||||
def flow_xz(x, z, t, sc):
|
||||
g = flow_global(x, 0.0, z, sc); ux, uz = g[0], g[2]
|
||||
if FLOW["slope"] or FLOW["swirl"]:
|
||||
n = normal(x, z, t); dx, dz = n[0], n[2]; l = math.hypot(dx, dz)
|
||||
if l > 0:
|
||||
dx, dz = dx / l, dz / l
|
||||
ux += dz * FLOW["swirl"] + dx * FLOW["slope"]; uz += -dx * FLOW["swirl"] + dz * FLOW["slope"]
|
||||
return ux, uz
|
||||
|
||||
# --- local quantities at a point (all pointwise) ---
|
||||
E = 6.0 # finite-difference step for flow and Hessian derivatives (flow scale 512)
|
||||
def smoothstep(a, b, v): v = max(0.0, min(1.0, (v - a) / (b - a))); return v * v * (3 - 2 * v)
|
||||
def deposition(s): # the operator's Slime Renderer.prefab Deposition curve
|
||||
return 0.0 if s > .8 else 2.0 * smoothstep(0.0, .6, s) ** .8
|
||||
def sig(v): return 1.0 / (1.0 + math.exp(-max(-40.0, min(40.0, v))))
|
||||
|
||||
def locals_at(x, z, t, sc):
|
||||
n = normal(x, z, t); s = math.acos(max(-1.0, min(1.0, n[1]))) / (math.pi / 2)
|
||||
uxp, uzp = flow_xz(x + E, z, t, sc); uxm, uzm = flow_xz(x - E, z, t, sc)
|
||||
uxq, uzq = flow_xz(x, z + E, t, sc); uxr, uzr = flow_xz(x, z - E, t, sc)
|
||||
dux_dx, duz_dx = (uxp - uxm) / (2 * E), (uzp - uzm) / (2 * E)
|
||||
dux_dz, duz_dz = (uxq - uxr) / (2 * E), (uzq - uzr) / (2 * E)
|
||||
div = dux_dx + duz_dz
|
||||
sn, ss, om = dux_dx - duz_dz, duz_dx + dux_dz, duz_dx - dux_dz
|
||||
W = sn * sn + ss * ss - om * om
|
||||
h0 = height(x, z, t)
|
||||
hxx = (height(x + E, z, t) - 2 * h0 + height(x - E, z, t)) / E ** 2
|
||||
hzz = (height(x, z + E, t) - 2 * h0 + height(x, z - E, t)) / E ** 2
|
||||
hxz = (height(x + E, z + E, t) - height(x + E, z - E, t) - height(x - E, z + E, t) + height(x - E, z - E, t)) / (4 * E * E)
|
||||
det = hxx * hzz - hxz * hxz
|
||||
ux, uz = flow_xz(x, z, t, sc); dx, dz = n[0], n[2]; dl = math.hypot(dx, dz); ul = math.hypot(ux, uz)
|
||||
a = 0.0 if dl == 0 or ul == 0 else (ux * dx + uz * dz) / (dl * ul)
|
||||
return s, div, W, det, a
|
||||
|
||||
# scale constants (set from the grid's own spread on the first pass)
|
||||
K = dict(div=1.0, W=1.0, det=1.0)
|
||||
CANDS = {
|
||||
"c0_slope_band": lambda s, div, W, det, a: deposition(s) / 2,
|
||||
"c1_windrows": lambda s, div, W, det, a: deposition(s) / 2 * sig(3 * -div / K["div"]),
|
||||
"c2_strain": lambda s, div, W, det, a: deposition(s) / 2 * sig(3 * W / K["W"]),
|
||||
"c3_saddle_links": lambda s, div, W, det, a: (0.0 if s > .8 else 1.0) * sig(3 * -det / K["det"]) * smoothstep(0.02, .25, s),
|
||||
"c4_links_windrows": lambda s, div, W, det, a: (0.0 if s > .8 else 1.0) * sig(3 * -det / K["det"]) * smoothstep(0.02, .25, s) * sig(3 * -div / K["div"]),
|
||||
# krill hold where the current runs along the well's contour: flow neither climbs nor falls (a ~ 0)
|
||||
"c6_band_soft_windrows": lambda s, div, W, det, a: deposition(s) / 2 * sig(1.5 * -div / K["div"]),
|
||||
"c7_band_wide_contour": lambda s, div, W, det, a: deposition(s) / 2 * (.25 + .75 * math.exp(-(a / .45) ** 2)),
|
||||
"c5_contour_currents": lambda s, div, W, det, a: deposition(s) / 2 * math.exp(-(a / .2) ** 2),
|
||||
}
|
||||
|
||||
def grid_pass(t):
|
||||
sc = scroll(t); rows = []
|
||||
for j in range(G):
|
||||
row = []
|
||||
for i in range(G):
|
||||
x = ((i + .5) / G - .5) * 2 * R; z = ((j + .5) / G - .5) * 2 * R
|
||||
row.append(None if x * x + z * z > R * R else locals_at(x, z, t, sc))
|
||||
rows.append(row)
|
||||
return rows
|
||||
|
||||
def std(vals):
|
||||
m = sum(vals) / len(vals); return math.sqrt(sum((v - m) ** 2 for v in vals) / len(vals)) or 1.0
|
||||
|
||||
# --- PNG ---
|
||||
def ramp(v): # dark navy -> teal -> pale gold
|
||||
v = max(0.0, min(1.0, v)); stops = [(0, (10, 14, 30)), (.45, (20, 120, 130)), (.8, (200, 210, 120)), (1, (255, 245, 210))]
|
||||
for (a, ca), (b, cb) in zip(stops, stops[1:]):
|
||||
if v <= b:
|
||||
f = (v - a) / (b - a); return tuple(int(ca[k] + (cb[k] - ca[k]) * f) for k in range(3))
|
||||
def write_png(path, w, h, px):
|
||||
raw = b"".join(b"\x00" + bytes(c for p in px[y * w:(y + 1) * w] for c in p) for y in range(h - 1, -1, -1))
|
||||
def chunk(t, d): return struct.pack(">I", len(d)) + t + d + struct.pack(">I", zlib.crc32(t + d) & 0xffffffff)
|
||||
with open(path, "wb") as f:
|
||||
f.write(b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", w, h, 8, 2, 0, 0, 0))
|
||||
+ chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b""))
|
||||
|
||||
def mark_bodies(px, w):
|
||||
for wl in WELLS:
|
||||
i = int((wl["pos"][0] / (2 * R) + .5) * w); j = int((wl["pos"][1] / (2 * R) + .5) * w)
|
||||
for di in range(-2, 3):
|
||||
for dj in range(-2, 3):
|
||||
if 0 <= i + di < w and 0 <= j + dj < w: px[(j + dj) * w + i + di] = (255, 60, 60)
|
||||
|
||||
# --- physarum A from the 2026-10-13 probe (ASCII 64x32) for a correlation against the slime look ---
|
||||
def physarum_ascii(name):
|
||||
p = r"C:\aeth-wt\fauna-target-r3\docs\research\2026-10-13-fauna-placement-probe\output.txt"
|
||||
lines = open(p, encoding="utf-8").read().splitlines(); rampc = " .:-=+*#%@"
|
||||
k = next(i for i, l in enumerate(lines) if l.startswith("@@MAP " + name))
|
||||
rows = [l for l in lines[k + 1:k + 40] if l.startswith("|")][:32]
|
||||
return [[rampc.index(c) for c in r[1:65]] for r in reversed(rows)] # printed top=y high
|
||||
|
||||
def corr(a, b):
|
||||
ma, mb = sum(a) / len(a), sum(b) / len(b)
|
||||
sa = math.sqrt(sum((v - ma) ** 2 for v in a)); sb = math.sqrt(sum((v - mb) ** 2 for v in b))
|
||||
return sum((x - ma) * (y - mb) for x, y in zip(a, b)) / (sa * sb or 1)
|
||||
|
||||
def hash01(i, j, salt):
|
||||
s = (i * 73856093 ^ j * 19349663 ^ salt * 83492791) & 0xffffffff
|
||||
s ^= 2747636419; s = (s * 2654435769) & 0xffffffff; s ^= s >> 16; s = (s * 2654435769) & 0xffffffff; s ^= s >> 16
|
||||
s = (s * 2654435769) & 0xffffffff; return s / 4294967295.0
|
||||
|
||||
ONLY = sys.argv[3].split(",") if len(sys.argv) > 3 else list(CANDS)
|
||||
MEMB = sys.argv[4].split(",") if len(sys.argv) > 4 and sys.argv[4] else []
|
||||
def main():
|
||||
tag = sys.argv[2] if len(sys.argv) > 2 else "live"
|
||||
if tag == "swirl": FLOW.update(swirl=6.0, slope=1.5)
|
||||
t0 = time.time(); T = 100.0
|
||||
L = grid_pass(T)
|
||||
flat = [v for r in L for v in r if v is not None]
|
||||
K["div"] = std([v[1] for v in flat]); K["W"] = std([v[2] for v in flat]); K["det"] = std([v[3] for v in flat])
|
||||
print(f"[{tag}] grid {G}x{G} at t={T}: {time.time() - t0:.1f}s; std div={K['div']:.4g} W={K['W']:.4g} det={K['det']:.4g}")
|
||||
phys = {n: [c for r in physarum_ascii(n) for c in r] for n in ("physarum A", "physarum B")}
|
||||
for name, f in CANDS.items():
|
||||
if name not in ONLY: continue
|
||||
vals = [[None if v is None else f(*v) for v in r] for r in L]
|
||||
mx = max(v for r in vals for v in r if v is not None) or 1
|
||||
px = [(0, 0, 0) if v is None else ramp(v / mx) for r in vals for v in r]
|
||||
mark_bodies(px, G); path = os.path.join(OUT, f"density_{name}_{tag}.png"); write_png(path, G, G, px)
|
||||
# 64x32 block means for correlation with the physarum maps
|
||||
bw, bh = G // 64, G // 32; blocks = []
|
||||
for by in range(32):
|
||||
for bx in range(64):
|
||||
cell = [vals[y][x] or 0 for y in range(by * bh, (by + 1) * bh) for x in range(bx * bw, (bx + 1) * bw)]
|
||||
blocks.append(sum(cell) / len(cell))
|
||||
cov = sum(1 for v in flat if f(*v) > .5 * mx) / len(flat)
|
||||
print(f" {name}: png {path}\n corr physarumA={corr(blocks, phys['physarum A']):.3f} physarumB={corr(blocks, phys['physarum B']):.3f} area>half-max={cov:.3f}")
|
||||
# members under fixed per-candidate thresholds (HZD dither shape): jittered lattice, cell C, hashed threshold
|
||||
C = 16.0; n = int(2 * R / C); P = 8.0
|
||||
for name in MEMB:
|
||||
f = CANDS[name]; mx = None; members = {}; t1 = time.time()
|
||||
for tt in (T, T + 1.0, T + P):
|
||||
sc = scroll(tt); m = set(); dens = {}
|
||||
for j in range(n):
|
||||
for i in range(n):
|
||||
x = (i + hash01(i, j, 1)) * C - R; z = (j + hash01(i, j, 2)) * C - R
|
||||
if x * x + z * z > R * R: continue
|
||||
d = f(*locals_at(x, z, tt, sc)); dens[(i, j)] = d
|
||||
if mx is None: mx = max(dens.values()) or 1
|
||||
for k, d in dens.items():
|
||||
if d / mx > hash01(k[0], k[1], 3) ** .5 * .9 + .1: m.add(k) # threshold in (.1, 1)
|
||||
members[tt] = m
|
||||
a, b, c = members[T], members[T + 1.0], members[T + P]
|
||||
print(f" members {name}: {len(a)} of ~{int(math.pi * (R / C) ** 2)} candidates; changed in 1 s {len(a ^ b) / max(1, len(a)):.3f}, in {P:.0f} s {len(a ^ c) / max(1, len(a)):.3f} ({time.time() - t1:.0f}s)")
|
||||
W2 = 600; px = [(10, 14, 30)] * (W2 * W2)
|
||||
for (i, j) in a:
|
||||
x = (i + hash01(i, j, 1)) * C - R; z = (j + hash01(i, j, 2)) * C - R
|
||||
pi_, pj = int((x / (2 * R) + .5) * W2), int((z / (2 * R) + .5) * W2)
|
||||
if 0 <= pi_ < W2 and 0 <= pj < W2: px[pj * W2 + pi_] = (235, 230, 170)
|
||||
mark_bodies(px, W2); path = os.path.join(OUT, f"members_{name}_{tag}.png"); write_png(path, W2, W2, px); print(f" png {path}")
|
||||
|
||||
if __name__ == "__main__": main()
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
"""Is density_c6's triangular lattice the FlowField law's own structure or a probe artifact?
|
||||
Transect along x at z = 300 (y = 0, t = 100, slope terms off: the global term alone), 0.5 u spacing over 2048 u.
|
||||
1. Kinks of the law: tri(v) = |frac(v) - .5| is piecewise linear, so Tri3D's derivatives jump where an argument of
|
||||
a tri crosses a multiple of 1/2. Predict those x from the law's own arguments (both octaves) and check where the
|
||||
largest convergence jumps sit.
|
||||
2. Finite-difference step: convergence with step 6 (probe and spec) vs step .5: correlation.
|
||||
3. float32: the flow evaluated with every input and the tri arguments rounded to float32 vs float64: max difference.
|
||||
"""
|
||||
import math, struct, sys
|
||||
sys.argv = sys.argv[:1]
|
||||
import habitat_probe as H
|
||||
|
||||
H.FLOW.update(swirl=0.0, slope=0.0)
|
||||
T = 100.0; sc = H.scroll(T); Z = 300.0; S = H.FLOW["scale"]; GOLD = H.GOLD
|
||||
|
||||
|
||||
def conv(x, z, e):
|
||||
a = H.flow_xz(x + e, z, T, sc); b = H.flow_xz(x - e, z, T, sc)
|
||||
c = H.flow_xz(x, z + e, T, sc); d = H.flow_xz(x, z - e, T, sc)
|
||||
return -((a[0] - b[0]) / (2 * e) + (c[1] - d[1]) / (2 * e))
|
||||
|
||||
|
||||
xs = [-1024 + .5 * k for k in range(4097)]
|
||||
c6 = [conv(x, Z, 6.0) for x in xs]; c05 = [conv(x, Z, .5) for x in xs]
|
||||
m6, m5 = sum(c6) / len(c6), sum(c05) / len(c05)
|
||||
r = sum((a - m6) * (b - m5) for a, b in zip(c6, c05)) / math.sqrt(sum((a - m6) ** 2 for a in c6) * sum((b - m5) ** 2 for b in c05))
|
||||
print(f"FD step 6 vs .5 along the transect: correlation {r:.3f}")
|
||||
|
||||
# predicted kink x: arguments of tri along the transect (y field = -scroll, z fixed), both octaves
|
||||
def kinks():
|
||||
out = []
|
||||
for oc, sh in ((1.0, sc[0]), (GOLD, sc[1])):
|
||||
py, pz = -sh, Z / S * oc
|
||||
ty, tz = H.tri(py), H.tri(pz)
|
||||
# tri(p.x) kinks: p.x = k/2; tri(p.z + tri(p.x)) and tri(p.y + tri(p.x)) kink where tri(p.x) + const = k/2
|
||||
for k in range(-40, 41):
|
||||
out.append(k / 2 * S / oc)
|
||||
for base in (pz, py):
|
||||
for k in range(-40, 41):
|
||||
tv = k / 2 - base # tri(p.x) must equal tv in [0, .5]
|
||||
if 0 <= tv <= .5:
|
||||
for m in range(-20, 21):
|
||||
for px in (m + .5 - tv, m + .5 + tv):
|
||||
out.append(px * S / oc)
|
||||
return sorted(set(round(v, 3) for v in out if -1030 < v < 1030))
|
||||
|
||||
|
||||
K = kinks()
|
||||
jumps = sorted(((abs(c05[k + 1] - c05[k]), xs[k]) for k in range(len(xs) - 1)), reverse=True)[:40]
|
||||
near = sum(1 for _, x in jumps if min(abs(x - k) for k in K) <= 1.0)
|
||||
print(f"law kink lines crossing the 2048 u transect: {len(K)}; of the 40 largest convergence jumps (step .5), {near} lie within 1 u of a predicted kink")
|
||||
spacing = sorted(K); gaps = [b - a for a, b in zip(spacing, spacing[1:]) if b - a > .5]
|
||||
print(f"median spacing of kink lines along x: {sorted(gaps)[len(gaps) // 2]:.1f} u (flow scale {S:.0f} u)")
|
||||
|
||||
|
||||
def f32(v): return struct.unpack("f", struct.pack("f", v))[0]
|
||||
|
||||
|
||||
md = 0.0
|
||||
for x in xs[::8]:
|
||||
a = H.flow_global(x, 0.0, Z, sc)
|
||||
b = H.flow_global(f32(x), 0.0, f32(Z), (f32(sc[0]), f32(sc[1])))
|
||||
md = max(md, abs(a[0] - b[0]), abs(a[2] - b[2]))
|
||||
print(f"flow with float32-rounded inputs vs float64: max |difference| {md:.2e} u/s (amplitude 15)")
|
||||
BIN
docs/research/2026-10-14-fauna-habitat-probe/members_c0_slope_band.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/members_c0_slope_band.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-only.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-only.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-times-contour-flow.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-times-contour-flow.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-times-convergence.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-times-convergence.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-times-strain.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_density_band-times-strain.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-only.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-only.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-times-contour-flow.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-times-contour-flow.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-times-convergence.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-times-convergence.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-times-strain.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_members_band-times-strain.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_nopop_cycle-sampled-all.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_nopop_cycle-sampled-all.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_nopop_cycle-sampled-flow.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_nopop_cycle-sampled-flow.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_nopop_presence-fade.png
(Stored with Git LFS)
Normal file
BIN
docs/research/2026-10-14-fauna-habitat-probe/option_nopop_presence-fade.png
(Stored with Git LFS)
Normal file
Binary file not shown.
32
docs/research/2026-10-14-fauna-habitat-probe/pop_cycle.py
Normal file
32
docs/research/2026-10-14-fauna-habitat-probe/pop_cycle.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# cycle-sampled-flow: band at now, convergence at the member's own cycle start (period 8 s, hashed phase).
|
||||
import math, sys, os
|
||||
sys.argv = sys.argv[:1]
|
||||
import habitat_probe as H
|
||||
H.FLOW.update(swirl=6.0, slope=1.5)
|
||||
P, F, C, R = 8.0, .1, 16.0, H.R
|
||||
cands = []
|
||||
for j in range(250):
|
||||
for i in range(250):
|
||||
x = (i + H.hash01(i, j, 1)) * C - R; z = (j + H.hash01(i, j, 2)) * C - R
|
||||
if x * x + z * z < R * R: cands.append((x, z, .1 + .9 * H.hash01(i, j, 3), H.hash01(i, j, 4)))
|
||||
sc0 = H.scroll(100.0)
|
||||
cands = [c for c in cands if H.deposition(H.locals_at(c[0], c[1], 100.0, sc0)[0]) / 2 > .05][:600]
|
||||
def start(t, ph): return math.floor(t / P + ph) * P - ph * P
|
||||
cache = {}
|
||||
def pres(c, t):
|
||||
x, z, th, ph = c; t0 = start(t, ph)
|
||||
key = (x, z, t0)
|
||||
if key not in cache: cache[key] = H.locals_at(x, z, t0, H.scroll(t0))[1]
|
||||
s = H.locals_at(x, z, t, H.scroll(t))[0]
|
||||
d = H.deposition(s) / 2 * H.sig(1.5 * -cache[key] / .15)
|
||||
return H.smoothstep(th - F, th + F, d), t0
|
||||
prev = None; maxd = 0.0; jumps = 0; boundary = 0
|
||||
for k in range(181):
|
||||
t = 100.0 + k / 60.0
|
||||
cur = [pres(c, t) for c in cands]
|
||||
if prev:
|
||||
for (a, s0), (b, s1) in zip(prev, cur):
|
||||
if s0 != s1: boundary += 1; continue # the cycle turned: the member is faded here by the flow-coupling ruling
|
||||
maxd = max(maxd, abs(a - b)); jumps += abs(a - b) > .25
|
||||
prev = cur
|
||||
print(f"cycle-sampled-flow: {len(cands)} candidates, 180 steps: max |d presence|/step within a cycle {maxd:.4f}, steps>0.25: {jumps}, cycle turns {boundary}")
|
||||
60
docs/research/2026-10-14-fauna-habitat-probe/pop_maps.py
Normal file
60
docs/research/2026-10-14-fauna-habitat-probe/pop_maps.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"""One image per option of aetheria-fauna:question:habitat-no-pop. Law: band-times-convergence (spec r1 constants),
|
||||
slope terms on, 16 u lattice thinned to every second cell on the shoulders (band > .05 at t = 100), fade .1,
|
||||
cycle period 8 s with a hashed phase. Steps of 1/60 s for 1 s. A dot is a hosted member at t = 100, brightness its
|
||||
presence; red marks a member whose presence moved by more than .1 in one step without its cycle turning
|
||||
(a pop); a cycle turn is excluded because the advected cycle fades the member there (fauna-flow-coupling-ruled).
|
||||
"""
|
||||
import math, os, sys
|
||||
sys.argv = sys.argv[:1]
|
||||
import habitat_probe as H
|
||||
|
||||
H.FLOW.update(swirl=6.0, slope=1.5)
|
||||
R, C, P, F, T = H.R, 16.0, 8.0, .1, 100.0
|
||||
n = int(2 * R / C); cands = []
|
||||
sc0 = H.scroll(T)
|
||||
for j in range(0, n, 2):
|
||||
for i in range(0, n, 2):
|
||||
x = (i + H.hash01(i, j, 1)) * C - R; z = (j + H.hash01(i, j, 2)) * C - R
|
||||
if x * x + z * z <= R * R and H.deposition(H.locals_at(x, z, T, sc0)[0]) / 2 > .05:
|
||||
cands.append((x, z, .1 + .9 * H.hash01(i, j, 3), H.hash01(i, j, 4)))
|
||||
|
||||
|
||||
def dens(s, div): return H.deposition(s) / 2 * H.sig(1.5 * -div / .15)
|
||||
def start(t, ph): return math.floor(t / P + ph) * P - ph * P
|
||||
|
||||
|
||||
cache = {}
|
||||
def at(x, z, t):
|
||||
k = (x, z, t)
|
||||
if k not in cache: cache[k] = H.locals_at(x, z, t, H.scroll(t))
|
||||
return cache[k]
|
||||
|
||||
|
||||
def presence(mode, c, t):
|
||||
x, z, th, ph = c; t0 = start(t, ph)
|
||||
if mode == "presence-fade": s, div = at(x, z, t)[0], at(x, z, t)[1]
|
||||
elif mode == "cycle-sampled-flow": s, div = at(x, z, t)[0], at(x, z, t0)[1]
|
||||
else: s, div = at(x, z, t0)[0], at(x, z, t0)[1] # cycle-sampled-all
|
||||
return H.smoothstep(th - F, th + F, dens(s, div)), t0
|
||||
|
||||
|
||||
for mode in ("presence-fade", "cycle-sampled-flow", "cycle-sampled-all"):
|
||||
prev = [presence(mode, c, T) for c in cands]; first = [p for p, _ in prev]; popped = set(); maxd = 0.0
|
||||
for k in range(1, 61):
|
||||
cur = [presence(mode, c, T + k / 60.0) for c in cands]
|
||||
for idx, ((a, s0), (b, s1)) in enumerate(zip(prev, cur)):
|
||||
if mode != "presence-fade" and s0 != s1: continue
|
||||
maxd = max(maxd, abs(a - b))
|
||||
if abs(a - b) > .1: popped.add(idx)
|
||||
prev = cur
|
||||
hosted = [i for i, p in enumerate(first) if p > 0]
|
||||
W2 = 600; px = [(10, 14, 30)] * (W2 * W2)
|
||||
for idx in set(hosted) | popped:
|
||||
x, z = cands[idx][0], cands[idx][1]; b = first[idx]
|
||||
col = (255, 50, 50) if idx in popped else tuple(int(30 + (c - 30) * b) for c in (235, 230, 170))
|
||||
pi_, pj = int((x / (2 * R) + .5) * W2), int((z / (2 * R) + .5) * W2)
|
||||
for di in (0, 1):
|
||||
for dj in (0, 1):
|
||||
if 0 <= pi_ + di < W2 and 0 <= pj + dj < W2: px[(pj + dj) * W2 + pi_ + di] = col
|
||||
H.mark_bodies(px, W2); p = os.path.join(H.OUT, f"option_nopop_{mode}.png"); H.write_png(p, W2, W2, px)
|
||||
print(f"{mode}: {len(cands)} shoulder candidates, {len(hosted)} hosted at t=100; 60 steps of 1/60 s: max |d presence| per step (cycle turns excluded) {maxd:.4f}, members popping (> .1 in a step) {len(popped)}; png {p}")
|
||||
28
docs/research/2026-10-14-fauna-habitat-probe/pop_probe.py
Normal file
28
docs/research/2026-10-14-fauna-habitat-probe/pop_probe.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# presence-fade under the c6 law (band x sigmoid(1.5 * conv / .15)), slope terms on, 1/60 steps over 3 s.
|
||||
import math, sys
|
||||
_argv = sys.argv; sys.argv = sys.argv[:1]
|
||||
import habitat_probe as H
|
||||
H.FLOW.update(swirl=float(__import__("os").environ.get("SWIRL", "6")), slope=float(__import__("os").environ.get("SLIDE", "1.5")))
|
||||
def smooth(a, b, v): return H.smoothstep(a, b, v)
|
||||
def density(x, z, t, sc):
|
||||
s, div, W, det, a = H.locals_at(x, z, t, sc)
|
||||
return H.deposition(s) / 2 * H.sig(1.5 * -div / .15)
|
||||
C, R = 16.0, H.R; cands = []
|
||||
for j in range(0, 250, 1):
|
||||
for i in range(0, 250, 1):
|
||||
x = (i + H.hash01(i, j, 1)) * C - R; z = (j + H.hash01(i, j, 2)) * C - R
|
||||
if x * x + z * z < R * R: cands.append((x, z, .1 + .9 * H.hash01(i, j, 3)))
|
||||
# keep candidates on the shoulders (band > .05 at t0) so the sample is the population that can host
|
||||
sc = H.scroll(100.0)
|
||||
cands = [c for c in cands if H.deposition(H.locals_at(c[0], c[1], 100.0, sc)[0]) / 2 > .05][:600]
|
||||
F = float(__import__("os").environ.get("FADE", ".05"))
|
||||
prev = None; maxd = 0.0; maxdd = 0.0; jumps = 0; steps = 180
|
||||
for k in range(steps + 1):
|
||||
t = 100.0 + k / 60.0; sc = H.scroll(t)
|
||||
d = [density(x, z, t, sc) for x, z, _ in cands]
|
||||
p = [smooth(th - F, th + F, v) for v, (_, _, th) in zip(d, cands)]
|
||||
if prev:
|
||||
for a, b, da, db in zip(prev[0], p, prev[1], d):
|
||||
maxd = max(maxd, abs(a - b)); maxdd = max(maxdd, abs(da - db)); jumps += abs(a - b) > .25
|
||||
prev = (p, d)
|
||||
print(f"fade {F}: {len(cands)} shoulder candidates, {steps} steps of 1/60 s: max |d presence|/step {maxd:.3f}, max |d density|/step {maxdd:.4f}, steps>0.25: {jumps}")
|
||||
Loading…
Reference in a new issue