Files
tokyo-wangan-racing/tools/control_and_connectivity.luau
T
jesse 1d23c187ad Daikoku PA: two perimeter ramps, far side served by the median opening
Rework the PA junction to match the reference drawing: yellow = PA -> highway
(entry), red = highway -> PA (exit). Entry and exit swap sides (entry now
EAST, exit WEST) and both trunks hug the PA perimeter instead of running
concentric spirals.

The simplification: both carriageways sit at the same deck level, adjacent,
so the median opening IS the far-side access path. The under-deck crossing
and merge runs are deleted outright -- 8 runs collapse to 4, and the
girder-soffit ceiling logic that constrained the crossing goes with them.
Part count 24,210 -> 21,691.

The median opening is now load-bearing rather than cosmetic (it is the only
route from the far carriageway to the ramps), so it widens from 6 to 9
samples per junction.

Orientation is a single flip-able constant (ORIENT) so a mirrored result is
a one-line correction, not a rewrite.

Measured on the built map (not asserted):
  - 600 entry + 600 exit ramp parts
  - max grade 8.00% / 8.27%, under the 9% limit
  - 0 collisions with piers/masts/girders (558 structural parts)
  - segment continuity <= 2.5 studs; trunk->merge handoff <= 1.7 studs
  - merge lands at dY 0.0 (exact deck level), 33 studs lateral
  - median open at junctions: 0 parts vs. control ~7 on plain mainline

Two traps worth recording, both caught by controls:

1. Studio's require() cache silently rebuilt STALE code. The first "passing"
   build reported 17,575 parts and zero ramps, and the map contained
   PAOffRamp/PAOnRamp parts whose names exist nowhere in the current source.
   Every measurement taken before this was describing an old map. Added
   tools/rebuild_fresh.luau, which clones the module to bust the cache; use
   it rather than requiring MapBuilder directly.

2. A reported "median never opens" bug was a bad probe, not a defect. It
   counted `Barrier` (the outer edge parapet, which must NEVER open) instead
   of `Median_<i>`. Re-run against the right name: control 7, junctions 0.

Both were only visible because the probes carry controls -- a 0-hit result
with no control is vacuous. The verification harnesses are kept in tools/
with their controls built in.
2026-08-03 11:53:40 -04:00

96 lines
2.8 KiB
Luau

-- CONTROL + CONNECTIVITY.
-- 1. Control: deliberately test a part known to intersect structure, so a
-- 0-hit result on the ramps means "clear", not "probe is broken".
-- 2. Connectivity: largest gap between consecutive deck segments within each
-- run, and the trunk->near handoff distance.
local ws = game:GetService("Workspace")
local map = ws:FindFirstChild("Map")
if not map then
return "no Map"
end
local structural, runs = {}, {}
for _, d in ipairs(map:GetDescendants()) do
if d:IsA("BasePart") then
local nm = d.Name
if nm:find("PierColumn") or nm:find("PAMast") or nm:find("GirderRib") then
table.insert(structural, d)
end
for _, base in ipairs({ "PAEntryRampTrunk", "PAEntryRampNear", "PAExitRampTrunk", "PAExitRampNear" }) do
if nm:sub(1, #base + 1) == base .. "_" then
runs[base] = runs[base] or {}
table.insert(runs[base], d)
end
end
end
end
local function overlaps(p, s)
local d1, d2 = p.Position, s.Position
return math.abs(d1.X - d2.X) < (p.Size.X + s.Size.X) / 2
and math.abs(d1.Z - d2.Z) < (p.Size.Z + s.Size.Z) / 2
and math.abs(d1.Y - d2.Y) < (p.Size.Y + s.Size.Y) / 2
end
local out = {}
-- CONTROL: a probe box placed exactly on the first structural part must hit.
local ctrl = structural[1]
local fake = { Position = ctrl.Position, Size = Vector3.new(4, 4, 4) }
local ctrlHits = 0
for _, s in ipairs(structural) do
if overlaps(fake, s) then
ctrlHits += 1
end
end
table.insert(
out,
("CONTROL (box on a known pier): hits=%d -> probe %s"):format(
ctrlHits,
ctrlHits > 0 and "WORKS" or "IS BROKEN/VACUOUS"
)
)
table.insert(out, "structuralParts=" .. #structural)
-- CONNECTIVITY
local function sortKey(p)
return tonumber(p.Name:match("_(%d+)$")) or 0
end
for _, base in ipairs({ "PAEntryRampTrunk", "PAEntryRampNear", "PAExitRampTrunk", "PAExitRampNear" }) do
local parts = runs[base]
if not parts then
table.insert(out, base .. ": MISSING")
else
table.sort(parts, function(a, b)
return sortKey(a) < sortKey(b)
end)
local maxGap = 0
for i = 2, #parts do
local g = (parts[i].Position - parts[i - 1].Position).Magnitude
maxGap = math.max(maxGap, g)
end
table.insert(out, ("%s: n=%d maxSegGap=%.1f"):format(base, #parts, maxGap))
end
end
-- Trunk -> Near handoff
for _, pair in ipairs({ { "PAEntryRampTrunk", "PAEntryRampNear" }, { "PAExitRampTrunk", "PAExitRampNear" } }) do
local t, nr = runs[pair[1]], runs[pair[2]]
if t and nr then
table.sort(t, function(a, b)
return sortKey(a) < sortKey(b)
end)
table.sort(nr, function(a, b)
return sortKey(a) < sortKey(b)
end)
local best = math.huge
for _, a in ipairs({ t[1], t[#t] }) do
for _, b in ipairs({ nr[1], nr[#nr] }) do
best = math.min(best, (a.Position - b.Position).Magnitude)
end
end
table.insert(out, ("HANDOFF %s->%s closestEnd=%.1f"):format(pair[1], pair[2], best))
end
end
return table.concat(out, "\n")