Policy 3 (headless + Unreal): walkable ring always first; at rest/arrival LOD0-2 before far; walking interleaves near:far ~4:1 toward heading; fast travel admits far coarse tiles right after the walkable ring. Hysteresis: walking 0.75/0.35 m/s, fast 12/8 m/s. Headless, far holes while moving 30 m/s: L77 9.0% / L79 77.2% / L80 8.9%. Cold LOD0-2 ready (one clean protocol, medians): SW 1.30, FI 3.61, TN 3.07, VS 1.43 s. Unreal 30 m/s traces end 2,233/2,237 loaded (commandlet readiness exit 1) for all policies. Passage zero-padding cut: ~50% fewer passage iterations on active tiles, max 6.6 cm surface displacement, no sign flips; not adopted yet (padding sweep next). World unchanged (v213). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
165 lines
8.4 KiB
Python
165 lines
8.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Run the Unreal null-RHI moving and dwell trace for L77/L79/L80."""
|
|
from __future__ import annotations
|
|
import csv
|
|
import json
|
|
import re
|
|
import subprocess
|
|
import time
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[4]
|
|
HOST = Path("/home/jahni/VFHost")
|
|
HOST_PLUGIN_SAVED = HOST / "Plugins/VoxelForge/Saved/Linux/l80"
|
|
HOST_SAVED = HOST / "Saved/Linux/l80"
|
|
EDITOR = Path("/home/jahni/UnrealEngine/Engine/Binaries/Linux/UnrealEditor-Cmd")
|
|
OUT = ROOT / "Saved/Linux/l80/movement/unreal"
|
|
SPAWN_M = (19.166015625, -14.2001953125, -753.3740234375)
|
|
SPEEDS = {"walk": 140.0, "fast": 3000.0}
|
|
POLICIES = {0: "L77", 2: "L79", 3: "L80"}
|
|
SAMPLE_SECONDS = 0.25
|
|
MOVE_START_S = 6.0
|
|
MOVE_DURATION_S = 12.0
|
|
DWELL_S = 5.0
|
|
EXIT_S = MOVE_START_S + MOVE_DURATION_S + DWELL_S
|
|
EVENT = re.compile(r"^\{" )
|
|
|
|
|
|
def parse_trace(path: Path, run: dict) -> tuple[list[dict], dict]:
|
|
events = []
|
|
if path.is_file():
|
|
for line in path.read_text(encoding="utf-8", errors="replace").splitlines():
|
|
if EVENT.match(line):
|
|
try:
|
|
events.append(json.loads(line))
|
|
except json.JSONDecodeError:
|
|
pass
|
|
samples = [e for e in events if e.get("type") == "streaming_sample"]
|
|
move = [e for e in samples if float(e.get("speed_cm_s", 0.0)) >= 50.0]
|
|
stop = next((e for e in events if e.get("type") == "streaming_test_move_stopped"), None)
|
|
stop_t = float(stop.get("t_s", 0.0)) if stop else (
|
|
float(move[0].get("t_s", 0.0)) + MOVE_DURATION_S if move else float("inf"))
|
|
dwell = [e for e in samples if float(e.get("t_s", 0.0)) >= stop_t
|
|
and float(e.get("speed_cm_s", 0.0)) < 50.0]
|
|
rows = []
|
|
for e in samples:
|
|
desired = e.get("desired_by_lod", [0] * 9)
|
|
resident = e.get("resident_by_lod", [0] * 9)
|
|
covered = e.get("covered_by_lod", resident)
|
|
far_desired = sum(desired[3:])
|
|
far_covered = sum(covered[3:])
|
|
rows.append({
|
|
"run": run["label"], "policy": run["policy"], "speed": run["speed"],
|
|
"t_s": e.get("t_s"), "speed_cm_s": e.get("speed_cm_s"),
|
|
"far_desired": far_desired, "far_covered": far_covered,
|
|
"far_hole_pct": round(100.0 * (far_desired - far_covered)
|
|
/ max(1, far_desired), 3),
|
|
"near_desired": sum(desired[:3]), "near_resident": sum(resident[:3]),
|
|
"near_ready_pct": round(100.0 * sum(resident[:3])
|
|
/ max(1, sum(desired[:3])), 3),
|
|
"phase": "move" if float(e.get("speed_cm_s", 0.0)) >= 50.0 else
|
|
"dwell" if float(e.get("t_s", 0.0)) >= stop_t else "arrival",
|
|
})
|
|
moving_rows = [r for r in rows if r["phase"] == "move"]
|
|
dwell_rows = [r for r in rows if r["phase"] == "dwell"]
|
|
summary = {
|
|
"moving_samples": len(moving_rows), "dwell_samples": len(dwell_rows),
|
|
"far_holes_moving_mean_pct": round(sum(r["far_hole_pct"] for r in moving_rows)
|
|
/ max(1, len(moving_rows)), 3),
|
|
"near_ready_moving_mean_pct": round(sum(r["near_ready_pct"] for r in moving_rows)
|
|
/ max(1, len(moving_rows)), 3),
|
|
"far_holes_dwell_last_pct": dwell_rows[-1]["far_hole_pct"] if dwell_rows else None,
|
|
"near_ready_dwell_last_pct": dwell_rows[-1]["near_ready_pct"] if dwell_rows else None,
|
|
"first_all_far_ready_s": next((r["t_s"] for r in moving_rows
|
|
if r["far_hole_pct"] == 0.0), None),
|
|
"move_stopped_t_s": stop_t if stop else None,
|
|
}
|
|
return rows, summary
|
|
|
|
|
|
def run(policy: int, speed_name: str) -> tuple[dict, list[dict]]:
|
|
label = f"{speed_name}-{POLICIES[policy]}"
|
|
trace, abslog, stdout = (OUT / f"{label}.trace.jsonl", OUT / f"{label}.log",
|
|
OUT / f"{label}.stdout.log")
|
|
output = HOST_PLUGIN_SAVED / "output" / label
|
|
userdir = HOST_SAVED / "user" / label
|
|
zendata = HOST_SAVED / "zen" / label
|
|
ddc = HOST_SAVED / "DDC"
|
|
for directory in (OUT, output, userdir, zendata, ddc):
|
|
directory.mkdir(parents=True, exist_ok=True)
|
|
spawn_cm = ",".join(f"{value * 100.0:.3f}" for value in SPAWN_M)
|
|
command = [
|
|
str(EDITOR), str(HOST / "VFHost.uproject"), "-nullrhi", "-unattended",
|
|
"-nop4", "-nosplash", "-NoSound", "-corelimit=12", "-NoZenAutoLaunch",
|
|
"-notraceserver", "-nocrashreports", "-DisablePlugins=AndroidFileServer",
|
|
"-ddc=NoZenLocalFallback", f"-userdir={userdir}", f"-ZenDataPath={zendata}",
|
|
f"-LocalDataCachePath={ddc}", "-run=VoxelForgeExplore", "-seed=0",
|
|
"-archetype=TunnelNetwork", "-slot=0", "-modes=export", "-gameconfig=1",
|
|
"-coreworldtest=1", "-ownerfourstrateplan=1", "-corevoxelsizecm=25",
|
|
"-coreislandtest=0", "-corefallbacktest=0", "-coreofftest=0", "-coreplantest=0",
|
|
"-settingsref=/Game/VoxelForge/DA_Settings.DA_Settings", "-corehybridmesher=0",
|
|
f"-out={output}", "-voxel.StreamingCoarseFirst=1",
|
|
"-voxel.StreamingDynamicNearReserve=1", "-voxel.StreamingLegacyPendingResultCap=0",
|
|
"-voxel.CoreRegionConcurrentAdmission=1", "-voxel.StreamingResultBacklogCap=256",
|
|
"-voxel.StreamingReadyQueueDepth=8", "-voxel.StreamingBackgroundWorkerCap=1",
|
|
"-voxel.CoreColumnCacheDirectMapped=0", "-voxel.CoreMCGradientMemoization=1",
|
|
"-voxel.StreamingCollisionLookahead=1", "-voxel.TestMove=1",
|
|
f"-voxel.TestMoveSpeedCmPerSecond={SPEEDS[speed_name]:.1f}",
|
|
f"-voxel.TestMoveStartSeconds={MOVE_START_S:.1f}",
|
|
f"-voxel.TestMoveDurationSeconds={MOVE_DURATION_S:.1f}",
|
|
f"-voxel.TestExitSeconds={EXIT_S:.1f}", "-voxel.TestMoveDirection=1,0,0",
|
|
f"-voxel.StreamingSchedulerPolicy={policy}", "-voxel.TestExitOnSteady=0",
|
|
"-coreworldstreamtrace=1", f"-voxel.StartupTraceSpawnCm={spawn_cm}",
|
|
"-voxel.StartupTraceUntilEndPlay=1", "-voxel.StartupTraceThroughCrossing=1",
|
|
"-voxel.StartupTraceMaxTiles=16384", f"-voxel.StartupTraceFile={trace}",
|
|
f"-abslog={abslog}",
|
|
]
|
|
wrapped = ["taskset", "-c", "0-11", "timeout", "1740s", *command]
|
|
start = time.monotonic()
|
|
with stdout.open("w", encoding="utf-8") as stream:
|
|
result = subprocess.run(wrapped, cwd=ROOT, stdout=stream,
|
|
stderr=subprocess.STDOUT, check=False, timeout=1740)
|
|
run_info = {"label": label, "policy": POLICIES[policy], "policy_id": policy,
|
|
"speed": speed_name, "speed_cm_s": SPEEDS[speed_name],
|
|
"exit_code": result.returncode, "wall_s": round(time.monotonic()-start, 3),
|
|
"trace": str(trace.relative_to(ROOT)), "abslog": str(abslog.relative_to(ROOT)),
|
|
"stdout": str(stdout.relative_to(ROOT))}
|
|
rows, summary = parse_trace(trace, run_info)
|
|
run_info.update(summary)
|
|
stdout_text = stdout.read_text(encoding="utf-8", errors="replace")
|
|
failure_match = re.search(
|
|
r"\[VoxelForgeCoreWorldTest\] failed: ([^\r\n]+)", stdout_text)
|
|
if result.returncode:
|
|
run_info["run_failure"] = (failure_match.group(1) if failure_match
|
|
else f"process exit {result.returncode}")
|
|
if (not rows or summary["moving_samples"] < 40 or summary["dwell_samples"] < 16):
|
|
raise SystemExit(f"Unreal trace incomplete: {stdout}; exit={result.returncode}; "
|
|
f"moving={summary['moving_samples']} dwell={summary['dwell_samples']}")
|
|
print("[L80UnrealMoveRun] " + json.dumps(run_info, sort_keys=True), flush=True)
|
|
return run_info, rows
|
|
|
|
|
|
def main() -> int:
|
|
if not EDITOR.is_file():
|
|
raise SystemExit(f"missing Unreal commandlet executable: {EDITOR}")
|
|
results, samples = [], []
|
|
for speed in ("walk", "fast"):
|
|
for policy in (0, 2, 3):
|
|
run_info, rows = run(policy, speed)
|
|
results.append(run_info)
|
|
samples.extend(rows)
|
|
(OUT / "runs-partial.json").write_text(json.dumps(results, indent=2) + "\n",
|
|
encoding="utf-8")
|
|
(OUT / "summary.json").write_text(json.dumps({"runs": results}, indent=2) + "\n",
|
|
encoding="utf-8")
|
|
if samples:
|
|
with (OUT / "samples.csv").open("w", newline="", encoding="utf-8") as stream:
|
|
writer = csv.DictWriter(stream, fieldnames=list(samples[0]))
|
|
writer.writeheader()
|
|
writer.writerows(samples)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|