Urban Vitality series · P9 · UE5 Logic Demo
P5 examined how a mature open-world runtime maintains lane topology, streamed road nodes, asynchronous routes, intersection signal groups, and traffic slots. P9 moves to the UE5 reconstruction. A standalone acceptance map implements a road graph, congestion-driven rerouting, downstream capacity, vehicle–pedestrian conflict scheduling, reservation expiry, and deterministic recovery. Vehicle following, braking, and collision belong to P11; Near/Mid/Far/Hidden presentation allocation belongs to P12.
Previous article: Urban Vitality P8 | UE5 Vehicle Scheduling: Garage Dispatch, Policy Arbitration, and Route Continuity
Related foundation: Urban Vitality P5 | Open-World Traffic Orchestration
Next article: Urban Vitality P10 | UE5 Pedestrian Motion: Fixed Steps, Crosswalk State, and Tiered Updates
Introduction: Traffic Orchestration Decides Who May Use the Next Piece of Space
Spline motion verifies route playback. Traffic orchestration must also manage four kinds of state: alternate routes after congestion changes, continuity while a route is replaced, allocation of limited downstream capacity, and clearance of a conflict zone after signal transitions or reservation failure.
The P9 acceptance map, /Game/Cyber2077/Maps/TrafficOrchestration_Demo, organizes these problems into a deterministic 32-second loop:
0–8 s FREE FLOW
8–16 s CONGESTION REROUTE
16–24 s DOWNSTREAM CAPACITY
24–32 s RESERVATION RECOVERY
The map contains a primary route, a southern bypass, a shared downstream-capacity gate, a signal conflict zone, and a pedestrian waiting area. Eight eastbound and six westbound vehicles circulate continuously. Yellow vehicles remain on the primary route; red vehicles have accepted a dynamic reroute. The HUD reports route costs, reroute counts, queued requests, reservation grants, capacity blocks, signal phase, active reservations, pedestrian groups, expired leases, and conflict-invariant violations.
| Demo phase | Operation and observation | Contract under test |
|---|---|---|
| Free Flow | Use the NETWORK view to establish the road and opposing traffic | Lane-graph data and fleet state are independent runtime data |
| Congestion Reroute | Raise the primary-route congestion cost; selected vehicles take the southern bypass | Only future lanes change; current lane, position, and speed remain continuous |
| Downstream Capacity | Three requests compete for one shared-exit credit in a single batch | At most one request becomes Granted; the others remain queued |
| Reservation Recovery | A pedestrian group waits for a conflict zone held by an orphan vehicle | After lease expiry, the group takes ownership under the real signal, within-type ordering, and starvation protection |
| Save / Restore | Capture the capacity or recovery phase, continue, then restore | Fleet, routing, queues, signals, reservations, and phase resume from the same fixed-step state |
Three fixed observation points are provided. CAM: NETWORK includes the western garage, primary route, southern bypass, and signal connection, making continuity before and after rerouting visible. CAM: BOTTLENECK faces the shared exit and exposes the three-request/one-credit result. CAM: SIGNAL focuses on the conflict zone and pedestrian waiting area, making VehicleGreen → AllStop → Pedestrian transitions and lease recovery easier to inspect.
The HUD separates evidence by module. The route panel shows the primary reference cost, selected-route cost, future-lane count, and current-lane-preserved state. The capacity panel shows Queued, Granted, and Capacity Blocked; Granted means a reservation was awarded, not that a vehicle passed the exit. The signal panel shows Phase, Elapsed, Pedestrian Demand, and current owners. The SOAK panel accumulates completed cycles, reroutes, reservation grants, expired leases, and conflict violations. Screenshots capture discrete states; the 50-second video is used to verify transition order.

From the Reference Runtime to UE5: The Road Network Is Live Data, Not Scene Decoration

Global traffic routing is also asynchronous: it has request tokens, bounded capacity, cancellation, and work that can continue across frames. Acceptance of a route request is not route completion, and a partial path is not final success. A signal does not directly rewrite every vehicle's speed. It produces a stop constraint that local motion can consume; predicted conflicts, static and dynamic occupancy, and traffic slots then determine how a vehicle approaches the intersection.
P9 does not reproduce offline compilation, streaming road nodes, or cross-frame A*. It retains five semantics that directly affect continuous operation:
- A lane is defined by a stable ID, topology endpoints, length, speed limit, and capacity.
- Route cost can combine distance, occupancy, congestion, and closure state.
- A reroute may replace only lanes the vehicle has not yet traversed.
- Signal permission and actual conflict-zone occupancy are separate conditions.
- Reservations must support queueing, release, timeout, and recovery.
The implementation uses project-owned runtime code. ZoneGraph, Mass Entity, and MassTraffic are not authoritative traffic data sources in this demo. The map Actor provides configuration and visualization; the road graph, fleets, dynamic routing, capacity reservations, and intersection scheduling live in C++ data structures that can execute without scene geometry.
Demo State Ownership

RoadGraph: primary, bypass, and opposing lanes;Fleet / OpposingFleet: route and motion state for eastbound and westbound vehicles;Reroute: per-vehicle blocked frames, last-reroute frame, and counters;CapacityReservations: pending requests, wait scores, and per-entry grant counts used for downstream competition;Scheduling: signals, vehicle reservations, pedestrian groups, leases, and conflict-zone occupancy.
The HUD and materials do not derive authoritative state. Scenario buttons advance real fixed steps to a target phase. Red vehicles, signal colors, and highlighted zones only present runtime results.
Mapping Source Semantics to Prototype Modules
The reference system assigns road data, global routing, traffic slots, intersection controllers, signals, and local vehicle movement to different modules. P9 keeps that separation of responsibility and recomposes it as independently testable contracts:
| Observable reference semantic | P9 module | Preserved now | Omitted now |
|---|---|---|---|
| Persistent road topology | Road Graph Runtime | Stable lane IDs, node connections, direction, length, speed, capacity | Offline baking, region streaming, road-version migration |
| Global route query | Dynamic Routing Runtime | Weighted cost, closure rejection, reconstruction, failure reasons | Cross-frame tokens, hierarchical graph, cache, cancellation protocol |
| Traffic-slot progression | Fleet Runtime | Vehicle identity, current lane, alpha, speed, future route | Reference slot layout, complete lane transforms, local conflict corridors |
| Downstream eligibility | Reservation Runtime | Requests, WaitFrames scoring, entry-grant penalty, one-batch exit credit, release | Live lane occupancy rate, vehicle length, clearance-time prediction |
| Intersection ownership | Intersection Scheduling | Signals, AllStop, vehicle leases, pedestrian groups, mutual exclusion | Network coordination, complex phases, network deadlock detection |
This mapping does not imply the omitted capabilities. A red vehicle completing the bypass proves route handoff on this small graph. It does not prove World Partition road-node streaming or cancellation of cross-region route tokens.
The reference runtime assigns these responsibilities to separate layers. Offline traffic compilation generates roads, splines, intersections, and persistent connectivity; the runtime manages node registration, deregistration, use counts, collision representations, and intersection objects. Global traffic paths enter a bounded queue as tokens, may be cancelled, and can continue across frames. Local vehicle motion consumes stop constraints generated by lights, lane slots, and predicted conflicts. P9 does not collapse these components into a single "reference traffic algorithm." It extracts boundaries that can be tested: topology precedes vehicles, route results are validated before commit, signal phases grant permission rather than occupancy, and actual occupancy must be released separately.
P5 established the persistent-road, streaming, asynchronous-routing, and traffic-slot evidence. P9 uses contracts extracted from those responsibilities. The RoadGraph, Routing, Reservation, and Scheduling types in this article are project-owned implementations, not classes from the reference codebase.
The UE5 prototype is divided accordingly. RoadGraph does not reference road meshes. Fleet retains VehicleId and route motion without using Actor pointers as identity. CapacityReservations owns path requests and credits. Scheduling owns signals, conflict zones, and leases. ACyberTrafficOrchestrationDemoActor remains an acceptance fixture and state-composition host. A production implementation can replace map construction, asynchronous search, or visualization while retaining these contracts.
Order Within One Fixed Step


The scene Actor also stores bRerouteTriggered, bCapacityScenarioStarted, and bRecoveryScenarioStarted. These markers are part of the scenario protocol. After checkpoint recovery they tell the runtime whether requests were already established, preventing elapsed time from replaying one-time side effects.
Tick only adds render-frame time to FixedStepAccumulator. Each available 0.1-second slice invokes AdvanceTrafficOrchestrationDemoFixedStep. The function resolves the phase, calls reroute, capacity, or recovery setup once, and then advances scheduling. During recovery, FCyberTrafficIntersectionSchedulingRuntime::Advance updates lease timers, signal transitions, and pending-request arbitration before the two fleets advance. Vehicles that reached the route end are recycled only when the entry envelope is clear, after which status is rebuilt for the HUD. Figure 4 compresses this call chain into phase, scheduling, and fleet bands. Its arrows denote order within one logical step, not parallel threads.
The visible fleets currently advance with an Open Gate. Capacity and signal results have not yet been connected to visible-vehicle braking. Capacity queues and conflict reservations provide independent scheduling evidence; motion execution remains P11's responsibility. P9 verifies calculation, persistence, and diagnostics of gating results, not end-to-end stopping at a red light or full downstream lane.
Dynamic Routing: Cost Changes Rewrite Only the Vehicle's Future
Two Competing Paths in the Road Graph
The eastbound entry runs from start to junction. The primary path continues through short.a and short.b; the alternate path enters a sequence of discrete lanes, curves south, and rejoins the destination. Eastbound lanes have stable IDs, From/To nodes, world endpoints, a 12 m/s speed limit, and capacity 6. A westbound lane with an 11 m/s limit and capacity 8 creates opposing flow.
The initial primary reference cost is the two-dimensional length of short.a + short.b. When Congestion Reroute begins, the system writes congestion 1.0 to both segments. Debug state also adds 500 to a primary-route reference value so before/after numbers are easy to compare. The authoritative route still comes from the dynamic router's per-lane calculation; it does not consume the HUD reference number.
Three Soft Costs and One Hard Closure

LaneCost = DistanceMeters × DistanceWeight
+ OccupancyCount × OccupancyWeight
+ Congestion × CongestionPenaltyScale
Defaults are 1 for distance, 40 per occupant, and 250 for congestion. A hard closure is rejected during candidate expansion instead of receiving an added cost. The result records evaluated, penalized, and closure-rejected lane counts separately. MaxLaneSegmentCount also rejects a reconstruction beyond the configured limit so malformed topology cannot produce unbounded predecessor traversal.
The policy structure contains IncidentPenalty, but the current FindRoute rejects closed lanes directly and does not apply that field as a finite incident cost. Its verifiable inputs are distance, occupancy, congestion, and hard closure; incident soft cost is not implemented.
The evidence scope differs for each input. The 32-second loop writes congestion 1.0 only to short.a and short.b, then evaluates eastbound vehicles until four reroutes succeed or all eight vehicles have been checked. BuildContext aggregates occupancy from lane-occupancy records; the caller supplies closures. Those latter paths are covered mainly by TrafficDynamicRouting automation. The main video proves congestion rerouting and continuous handoff, but it does not by itself prove occupancy weighting and closure rejection occurred in the recorded frame.
Distance is computed from world endpoints in two dimensions and divided by 100 to obtain meters. Adjustable weights are clamped non-negative, with distance weight no lower than 0.001. A bidirectional lane can expand from To back to From; a normal directed lane expands only From→To. Every relaxation increments EvaluatedLaneCount; a closure increments ClosedLaneRejectedCount; use of occupancy or congestion increments PenalizedLaneCount. These are search-process diagnostics, not traffic-volume statistics.
A Reroute Trigger Is Not a New Route

After the trigger gate, the query begins at the current lane's exit node rather than reprojecting the world position. If the result contains the same future lanes, the runtime returns reroute_unchanged. No route, invalid target, segment-limit overflow, and discontinuous topology produce separate failure reasons.
Preserve Current Lane, Motion State, and Identity


current lane PRESERVED.ApplyRoutePreservingCurrentLane copies the current lane first, then validates every connection in the new lane-ID sequence. The query source must equal the current lane's To node; every following From node must equal the previous To node; the final node must reach the target. Only after all checks pass does the function replace RouteLanes once.
The current lane becomes element 0 and CurrentLaneIndex returns to 0. LaneAlpha, position, speed, and VehicleId remain unchanged. The vehicle enters the alternate route only after finishing its current lane; it does not teleport to the bypass origin.
During the congestion phase, the demo evaluates the eastbound fleet until four reroutes succeed or all eight vehicles have been checked. Status stores selected route cost, future-lane count, and bCurrentLanePreserved. Red is assigned only after a new route is applied. Continuity is a runtime result, not a conclusion inferred from color.
Search scope: a synchronous small graph.
The router traverses the entire demo graph inside one function call. It has no cross-frame budget, priority queue, or graph partition. This is appropriate for validating weights and handoff, not evidence that a production city can synchronously search a global graph for many vehicles each frame. Scaling requires hierarchy, caching, a query queue, and time slicing while preserving cooldown and atomic replacement.
Shortest-path diagnostics.
The deterministic small-graph search stores minimum cost per node, predecessor lane, and a pending-node set. Each iteration selects the node with the lowest accumulated cost, enumerates outgoing lanes, and writes improved costs. On reaching the target, it walks predecessor lanes backward and reverses them into an ordered route.
The scan does not use a priority queue and is not suitable for a large network. In tests, it reproducibly identifies the lanes evaluated, penalized, or rejected. A result stores more than success or failure:
- whether a complete route was found;
- total cost and ordered lane segments;
- evaluated lane count;
- lane count affected by occupancy or congestion;
- lane count skipped because of closure;
- failure reason and segment-limit overflow.
These fields locate a route failure in its inputs. No route may mean an unreachable target, no outgoing edge, every candidate closed, or predecessor reconstruction beyond the segment limit. Returning only an empty array would leave the demo unable to distinguish bad data from a policy outcome.
Validate first, commit once.
A new route must not mutate vehicle state during validation. If three segments connect and a fourth points to the wrong node, incremental writes would leave a partially replaced path. P9 validates a temporary array:
- the current lane exists and can be element 0;
- the query begins at the current lane's exit;
- each From node matches the previous To node;
- every lane ID resolves in the Road Graph;
- the last segment reaches the target;
- the route stays within the runtime segment limit.
The complete temporary array replaces the future route only after all checks pass. The same commit boundary remains necessary after asynchronous search: a query may produce candidates over several frames, but the authoritative route changes only when a complete result validates.
Occupancy, Congestion, and Closure Are Different Inputs
Occupancy and Congestion both become comparable costs, but they originate from different state. Occupancy is the number of logical vehicles currently assigned to a segment. Congestion is an external 0–1 scalar that may represent reduced speed, incident influence, or regional policy. Closed means the lane is not a legal candidate.
Soft costs let the query trade a long detour against a crowded primary route. Hard closure does not participate in that trade. A partial incident needs an explicit production rule: close the entire segment, reduce capacity, or apply a recoverable soft cost. P9 currently uses hard closure, and IncidentPenalty does not enter the formula.
Capacity Gating: A Green Signal Does Not Guarantee Downstream Space


A signal permission says a movement may enter the intersection. If the downstream lane is already full, issuing another permission can strand a vehicle inside the conflict zone. P9 uses FCyberTrafficIntersectionReservationRuntime to verify downstream gating within one processing batch.
At phase entry the demo creates three requests for different conflict zones, all targeting Exit Lane lane.article3.shared.exit. With the gate closed, they enter the pending array carrying VehicleId, entry, exit, request frame, and wait frame. One batch then opens the gate and permits up to three grants but provides only one exit credit:
ExitLaneCapacity[shared.exit] = 1
Only one reservation can be granted. The other two remain pending and accumulate CapacityBlocked. Capacity is consumed by exit rather than conflict zone, so distinct entries cannot bypass a shared downstream bottleneck in the same batch. Granted means scheduling ownership was awarded; it does not mean the vehicle entered or crossed the exit.
Three counters must remain distinct. Queued is the number of pending capacity requests. Granted counts requests that received complete path reservations. CapacityBlocked counts processing events denied by insufficient exit credit and is therefore not the current queue length.
| Runtime term | Meaning in this article |
|---|---|
| Queued | Pending reservation request |
| Granted | Reservation awarded; the intersection has not necessarily been crossed |
| Active Reservation | Ownership of future conflict space |
| Crossing Agent | Object that has entered or still occupies the conflict zone |
| Released | Reservation ownership ended |
| Cleared | Actual conflict-zone occupancy ended |
The demo represents capacity as integer credit. It does not model flow rate, queue length, vehicle dimensions, or downstream clearance time. It validates the interface where a batch reads downstream budget before granting a reservation; a production capacity model must also consume lane occupancy and vehicle envelopes.
Request lifecycle from queue to release.
The capacity runtime separates pending requests, granted reservations, and exit-credit consumption. A new request validates vehicle, entry, exit, and conflict-zone IDs, then receives a monotonic sequence. Batch processing selects candidates stably and checks gate state, conflict availability, and exit credit in order.
After grant, the request moves from the pending array to a conflict reservation that retains VehicleId, entry, exit, conflict zone, and remaining lease. Exit credit is currently consumed through GrantedCountByExitLane only inside one ProcessFairQueueBatch invocation, which guarantees one grant among the three requests in that batch. An active Reservation continues to own its conflict zone, but the next batch does not automatically subtract that reservation from a new exit budget.
P9 verifies shared-exit credit within one batch. It does not maintain downstream in-flight credit across fixed steps. Production code must recompute each step's budget from active reservations, actual occupancy, and vehicles that entered but have not cleared, or represent credits as tokens with their own lifecycle. Otherwise two consecutive batches that both receive shared.exit = 1 may issue a second grant before the first vehicle clears.
A request denied for capacity remains at its array position and increments WaitFrames on the next batch. The current selection score is:
Score = WaitFrames × 100 - DirectionGrantCount(EntryLane)
Longer waits increase the score. Previous grants to the same entry lower it. Stable array order resolves equal scores. This is not an independent global-sequence protocol, but it prevents a failed request from being deleted and reinserted at the tail, and it applies a small penalty to repeatedly successful entries.
Capacity lookup prefers Exit Lane and falls back to Entry Lane only when no exit budget exists. Multiple entries merging into one exit therefore share one pool. When both entry and exit budgets exist, the exit value wins; they are not added to increase throughput.
Where production capacity credit comes from.
The fixture supplies shared.exit = 1 directly.

Conflict Zones: Signal Phase and Actual Occupancy Jointly Control Entry
Vehicles and Pedestrians Share Space but Use Two Arbitration Passes
FCyberTrafficIntersectionSchedulingRuntime maintains signals, pending vehicles, pending pedestrian groups, active vehicle reservations, active pedestrian groups, and actual Crossing Agents. Vehicle and pedestrian-group requests draw from one monotonic NextRequestSequence, giving both record types a common time base. ProcessFairRequests does not merge them into a global priority queue. It sorts pedestrian requests by waiting time and Sequence first, then processes vehicle requests under the same within-type rule.
A pedestrian-group request validates unique GroupId, SignalId, ConflictZoneId, and AgentIds, then increments Pedestrian Demand on the signal. A vehicle request stores LaneId for intersections with primary and secondary movement windows. Duplicate requests do not create duplicate ownership: an already-active request returns Granted; an already-pending request returns Queued with accumulated wait.
Signal Transitions Include an AllStop Clearance Window


Without extended movement windows, a signal starts in VehicleGreen. It can enter AllStop or PedestrianCrossing only when pedestrian demand exists, minimum vehicle-green time has elapsed, and the signal has no active vehicle. If Clearance Duration is configured, AllStop occurs before pedestrian entry.
When the pedestrian phase expires while a Crossing Agent remains, phase time clamps at its limit and extension count increases. The signal returns through a second AllStop to VehicleGreen only after actual occupancy clears. Expiry of the permission window does not forcibly delete an object still in the intersection.
Emergency AllStop is a separate state. A request takes the maximum of current remaining time and the new duration, and clears vehicle reservations plus lane and lease mappings. Neither vehicles nor pedestrians can newly enter during this state. It is a recovery guard, not a normal signal color.
Conflict-Zone Ownership Must Be Mutually Exclusive
A vehicle reservation requires VehicleGreen and no Crossing Agent in the conflict zone. A pedestrian group requires a pedestrian-permitted phase and no vehicle reservation in that zone. SetCrossingAgent rejects an insert while an active vehicle exists; vehicle reservation likewise fails while pedestrians occupy the zone.
The demo checks every step:
ActiveVehicleReservations is empty
OR ActivePedestrianGroups is empty
If both are non-empty, ConflictInvariantViolationCount increments. This aggregate is valid for the demo's single acceptance conflict. A general road network must check per ConflictZoneId rather than treating any vehicle reservation and any pedestrian group in the city as conflicting.
Orphan Reservations Recover Through Deterministic Leases


pedestrian resumed YES and mutual exclusion remain true.The recovery phase creates vehicle reservation vehicle.article3.orphan with a one-second lease and then stops sending progress heartbeats. A pedestrian group requests the same conflict zone and waits.
Each Advance subtracts from active vehicle leases. Only ReportVehicleProgress refreshes a VehicleId's lease to the configured duration. With no heartbeat, the orphan reaches zero and is removed from every conflict-zone, signal, lane, and lease map; ExpiredVehicleReservationCount increments. The signal can then enter a pedestrian window, where within-type ordering and starvation protection activate the waiting group. The HUD reports Pedestrian Recovered.
Timeout is not a blanket mechanism for deleting every slow vehicle. Production lease duration must account for network delay, speed, and intersection dimensions, and a valid vehicle must keep sending heartbeats. P9 verifies only that loss of an owner cannot permanently lock the intersection.
Four Conditions Between Green and Physical Entry

| Condition | Decision | Outside this layer |
|---|---|---|
| Signal phase | Is the current movement in a permission window? | Does not guarantee the conflict zone is clear |
| Conflict ownership | Does a vehicle or pedestrian already own shared space? | Does not guarantee downstream capacity |
| Exit capacity | Can the downstream lane accept this movement? | Does not decide how the vehicle brakes |
| Local vehicle motion | Can spacing and stop-line control execute the permission? | Does not rewrite signals or reservations |
Signal permission, conflict ownership, downstream capacity, and local movement all constrain entry. P9 implements scheduling state for the first three and leaves the fleet advance as a consumer seam. These outputs do not yet make visible vehicles brake or wait at a stop line; body execution belongs to P11. The demo verifies layer boundaries and scheduling results, not end-to-end physical passage. Each layer should retain its own wait reason. A single CanGo Boolean cannot distinguish a red signal, pedestrian owner, lead vehicle, or full downstream lane.
Reservation Ownership and Crossing Agent Are Different States
A reservation means an object is eligible to enter and owns future conflict space. A Crossing Agent means the object entered or still physically occupies that space. Their lifetimes may overlap, but their boundaries differ. A vehicle may hold a reservation before entering, or continue heartbeats after entry. A pedestrian group must wait for all members to clear before actual occupancy ends.
Signal state therefore cannot depend on reservation count alone. A released vehicle reservation does not permit pedestrians to take over if a Crossing Agent remains. Conversely, a holder that never entered and no longer reports progress must be recoverable through lease expiry. The orphan fixture targets the latter failure.
A Shared Sequence Is Not Strict Cross-Type FIFO

A request that is not yet eligible remains pending. A pedestrian without a crossing window stays in PendingPedestrianGroups; a vehicle blocked by phase, pedestrian occupancy, or incompatible lane stays in PendingVehicles. A pedestrian waiting beyond MaximumFairWaitSeconds increments StarvationPriorityCount and defers new vehicle grants for the same conflict zone. Pedestrian Demand also drives the signal through AllStop into a pedestrian window once minimum vehicle-green time and clearance conditions are met.
The implementation covers pedestrian wait protection and mutually exclusive ownership, but it is not a general global-fairness scheduler. If production requires vehicles, individuals, and groups to share one priority comparison, both Pending Maps must be projected into one candidate set and compared in a single arbitration over wait, Sequence, emergency priority, and phase-switch cost. Shared Sequence can remain the stable tie-breaking basis.
Fixed Steps, Scenario Control, and Checkpoint Recovery
The demo runs at a 0.1-second fixed step. Each step advances the 32-second loop and resolves phase, performs one-time reroute, capacity, or recovery initialization, advances signal and lease state during recovery, updates conflict statistics, then advances eastbound and westbound fleets. A vehicle at route end returns to the start only when the entry envelope is free.
NEXT PHASE and the five scenario buttons do not write HUD state. They temporarily resume the fixed-step loop and run to 8.1, 16.1, 24.1, or 25.2 seconds, then restore the previous pause state. If current time is already past the target, the scene resets and advances again. The buttons reduce waiting during acceptance without introducing a separate result path.
Pause Freezes Only the Authoritative Fixed Step
PAUSE makes AdvanceTrafficOrchestrationDemoFixedStep return without changing FrameIndex, ElapsedSeconds, fleets, queues, or leases. Cameras and HUD remain available. Automation pauses and saves at step 69, confirms that state does not change while paused, then resumes into the reroute phase.
The Snapshot Covers the Scheduling Scene


The checkpoint contains Road Graph, both fleets, per-vehicle reroute state, capacity reservations, the Scheduling snapshot, aggregate demo state, and all three phase-initialization flags. Current cross-reference validation is limited to version-1 Scheduling data. It checks:
- active vehicle reservations have non-empty ConflictZone keys and VehicleIds, plus Lane, valid Signal, and Lease mappings;
- pending-vehicle map keys match their VehicleIds;
- every AgentId in an active pedestrian group appears in the same conflict zone;
- pending pedestrian groups reference valid signals, zones, and members.
Scheduling state is applied only after validation. The fixed-step accumulator is reset and presentation rebuilt. RoadGraph, Fleet, Reroute, Capacity, and aggregate demo state are still copied directly from the same-session snapshot; P9 does not yet have a schema, resource-version check, or cross-module preflight for the complete state. As in P8, render-time remainder below one fixed step is not saved. Recovery resumes from a fixed-step boundary rather than providing frame-exact replay.
RESET rebuilds Free Flow and clears SOAK aggregates such as Completed Cycle, reroutes, capacity grants, expired leases, and conflict violations. It retains the Runtime Checkpoint and capture/restore counts. Resetting runtime state and deleting a checkpoint are separate operations.
Validate internal references before applying recovery.
Scheduling consists of several ID-keyed tables. Every table may appear valid in isolation while their composition contains dangling references: an active reservation names a missing signal; a Lease Map has a vehicle absent from Reservation Map; a pedestrian group declares three members but Crossing Agent contains two; or a pending map key differs from its embedded VehicleId.
P9 rejects incomplete Scheduling substate before write, then replaces Scheduling as a unit and rebuilds scene presentation. This avoids partial recovery caused by field-by-field mutation. Cross-module validation of the complete P9 snapshot remains unimplemented.
Road graph, fleets, and demo aggregates are still same-session copies without disk migration. A future SaveGame needs at least a data version, Road Graph resource version, remapping for invalid lane IDs, fallback rules for deleted signals and conflict zones, and cleanup rules for old capacity reservations.
Reproducible Buttons Are Acceptance Tools
Scenario buttons map manual inspection to deterministic logical times without writing display state. Capacity advances to 16.1 seconds, after one-time initialization; Recovery advances to 25.2 seconds so the lease expires and the pedestrian group resumes.
Deterministic jumps make regressions repeatable. HUD, request sequences, and vehicle state can be compared at the same logical time before and after a code change. Automation and recorded walkthroughs use the same fixed-step path rather than a test-only result generator.
Acceptance and Capability Boundaries
Every Phase Must Preserve the Same Invariants
The four phases exercise different scheduling conditions, but acceptance cannot check only the most visible phase counter. P9 continuously maintains these invariants:
| Invariant | Typical failure | Diagnostic evidence |
|---|---|---|
| VehicleId uniqueness | Reset or reroute creates a duplicate vehicle | Identity sets in both fleets |
| Current-lane continuity | A new route overwrites the current lane | bCurrentLanePreserved, position, alpha |
| Route-topology continuity | New segment From/To does not connect | Route-apply failure reason |
| No exit-credit overgrant within one batch | Different zones consume the same shared exit independently | Granted and CapacityBlocked |
| Mutually exclusive conflict ownership | Vehicle reservation and pedestrian group active together | Conflict Invariant Violation |
| Recoverable lease | Orphan reservation owns the zone forever | Expired Reservation Count |
| Pause does not advance | UI says paused while leases count down | Frame, Elapsed, Lease Remaining |
| Recovery does not replay side effects | Phase initialization recreates requests | Initialization flags, request count, aggregates |
Capacity and Pedestrian counts may be zero during Free Flow, yet route continuity, identity uniqueness, and pause semantics still apply. Successful lease expiry during Recovery also cannot hide a step on which both owner types were active. Soak tests check whether these invariants survive phases and loop boundaries.
The HUD only reads runtime state.
The HUD owns no business counters. Selected Route Cost comes from the last route query. Queued, Granted, and Blocked come from capacity state. Signal Phase, Active Reservation, and Pedestrian Group come from Scheduling. Fleet counts, current route, and reroute markers come from Fleet/Reroute.
This read-only relationship lets automation inspect the same state without a HUD and permits UI replacement without changing runtime behavior. If the HUD accumulated "rerouted vehicles" itself, Reset, Restore, and loop boundaries could diverge from authoritative state.
Failure Paths Also Belong in Manual Acceptance
The main video records successful rerouting, one-credit batch allocation, and lease recovery. Engineering acceptance also covers failure: close both primary and bypass routes and expect unreachable; supply a disconnected lane and reject route application; set exit credit to zero and preserve request position and WaitFrames; submit the same VehicleId twice and avoid duplicate ownership; load an invalid Scheduling snapshot and fail before state write.
These cases need not all appear in the article's main visuals, but they belong in project acceptance. They confirm that invalid input cannot create partial state and complement the successful paths recorded in the main video.
Manual Walkthrough
- Use
CAM: NETWORKto establish garage, primary road, southern bypass, exit gate, and signal zone. - Observe Free Flow and confirm that 14 vehicles continue circulating.
- Press
CREATE CONGESTIONorPENALIZE PRIMARY; confirm red vehicles finish their current lane before entering the bypass. - Switch to
CAM: BOTTLENECK, pressLIMIT EXIT, and verify that only one of three requests becomes Granted. This is a reservation grant, not physical passage. - Switch to
CAM: SIGNAL, triggerPEDESTRIANandSTALE LEASE, and observe orphan expiry followed by pedestrian ownership. - SAVE STATE during capacity, continue into recovery, then RESTORE and confirm the same transition can occur again.
- Run several cycles and keep SOAK conflict violations at 0.
Automated Evidence


TrafficDynamicRouting verifies weighted paths with congestion and closure context plus current-lane-preserving handoff. CityFlowSchedulingLifecycle covers capacity wait scores, one-batch grant budget, and release. TrafficSignalInterlock covers vehicle/pedestrian permission, clearance, within-type ordering, cross-type starvation protection, and mutual exclusion.
TrafficOrchestrationArticle3Demo checks pause, scenario jumps, reroute, one-credit batch capacity, lease expiry, pedestrian recovery, checkpoint, and continued execution. TrafficOrchestrationArticle3DemoMap verifies map, labels, fixed cameras, GameMode, and HUD wiring. TrafficOrchestrationArticle3Soak runs 1,281 fixed steps at 0.1 seconds over four complete loops and expects 16 successful reroutes, four reservation grants, four orphan-lease expiries, and zero conflict-invariant violations.
| Counter | Unit in code | Accumulates across cycles | Four-cycle expectation |
|---|---|---|---|
CumulativeRerouteCount |
Successful dynamic-route application; target four per cycle | Yes | 16 |
CumulativeCapacityGrantCount |
Reservation grant inside one processing batch; one per cycle | Yes | 4 |
CumulativeExpiredLeaseCount |
Orphan vehicle lease-expiry event; one per cycle | Yes | 4 |
ConflictInvariantViolationCount |
Fixed step with vehicle reservation and pedestrian group active together | Yes | 0 |
Evidence capture saves Downstream Capacity at step 171, advances into Reservation Recovery, then restores. Phase, Time, route, capacity, signal, and conflict state return to the capture point. AllStop and pedestrian takeover occur on adjacent authoritative steps 251 and 252. At step 1281 the run has completed four loops with 16 reroutes, four capacity grants, four orphan-lease expiries, and zero Conflict Invariant Violations.
P9 is frozen under tags article3-traffic-orchestration-demo-v1/v2. The candidate passed compilation, general Smoke, ValidationAll, Standalone operation checks, and multi-cycle observation. Four known warnings in the combined ValidationAll environment are not P9 road-data failures.
The primary scenario covers:
- congestion-driven rerouting while current lane, VehicleId, position, and speed remain continuous;
- three requests competing for one shared-exit credit in the same
ProcessFairQueueBatch, with one reservation Granted; - AllStop clearance, deterministic orphan-lease expiry, and subsequent pedestrian ownership;
- recovery and continuation of fleet, routing, capacity, signal, reservation, and phase state;
- RESET clearing SOAK aggregates while retaining checkpoint and capture/restore counts.
Automation additionally covers:
- distance, occupancy, and congestion soft costs plus hard closure on the project-owned small graph;
- rejection of disconnected and unreachable routes and invalid Scheduling snapshots;
- duplicate-request suppression, capacity wait scoring, within-type ordering, and pedestrian starvation protection;
- four-cycle totals of 16 reroutes, four capacity grants, four lease expiries, and zero conflict violations.
It does not cover offline road baking, World Partition streaming, time-sliced large-graph routing, multi-lane changes, complex phases, network deadlock, physical vehicle-envelope clearance time, or target-platform routing budgets. Vehicle motion and collision remain P11; citywide presentation cost remains P12.
Contracts That Must Survive Migration to a City Network
As routing becomes asynchronous, the following state contracts remain necessary:
- a query token can be cancelled, but the old route remains valid until a new route commits;
- unloading a local graph region gives stable lane IDs and saved data an explicit invalidation path;
- congestion can change without causing cooldown-free reroute oscillation;
- an active reservation releases ownership only on completion, cancellation, or timeout; cross-step exit-credit lifecycle still needs a separate implementation;
- signal permission cannot override actual conflict occupancy;
- vehicle and pedestrian wait reasons remain separately diagnosable;
- a Scheduling snapshot validates internal cross-table references first; production recovery must extend this to RoadGraph, Fleet, Reroute, Capacity, and phase state before rebuilding visible objects.
Scaling requires measurements of route-queue length at several graph sizes, node expansions per frame, cache hit rate, congestion-update frequency, reservation-wait distribution, false lease-recovery rate, and cross-region recovery time. The small-graph contracts should move into a city runtime only after these measurements stabilize.
Demo colors are diagnostic only.
Primary routes, bypass routes, waiting vehicles, reservation holders, and conflict zones use different colors so state remains legible in one frame. Color does not participate in route, capacity, or scheduling decisions; the HUD only reads runtime results. Replacing every material with gray must not change fixed steps or test counters.
A presentation phase can replace those colors with road markings, signal heads, brake lights, and pedestrian actions while retaining a separate Debug View. A single frame of a stopped vehicle cannot reveal whether the cause was route failure, full exit, ungranted reservation, or a lead vehicle. P9's diagnostic fields remain useful for editor overlays and production logs.
Interface Boundaries with P8, P10, and P11
P8 decides which stable vehicle identity may leave the garage and supplies the initial route need. P9 decides which road space it may use next. P11 executes body spacing, braking, and risk actions. P10 submits pedestrian crossing demand and actual occupancy through the shared Conflict Zone and signal interface.
P8 vehicle dispatch and policy eligibility
↓ VehicleId / Route Need
P9 road graph, route, capacity, and passage ownership
↓ Route / Gate / Reservation
P11 vehicle motion, headway, braking, and collision
P10 pedestrian Crosswalk Demand
↕ Signal / Conflict Zone
P9 intersection scheduling
P9 does not move vehicle Actors directly. It outputs route and passage constraints for the motion layer to consume. Pedestrian systems submit demand and actual occupancy; intersection scheduling returns permission. P11 body models and P10 character animation can therefore change without rewriting the signal state machine or conflict ownership.
Conclusion: Passage Rights Emerge from Topology, Capacity, and Ownership
P9 decomposes traffic orchestration into three recoverable decisions. Dynamic routing selects future space. A capacity gate limits reservation grants within one processing batch. Conflict-zone reservations record ownership of shared space between vehicles and pedestrians. Signals provide permission windows but cannot replace actual occupancy. A reroute provides a new future but cannot break current vehicle continuity. A lease provides fault recovery but cannot replace progress heartbeats from a valid owner. The execution chain from scheduling state to body braking and physical passage remains P11's task.
P10 returns to pedestrians. Once population identity and intersection permission exist, a fixed-step SoA must advance pedestrian space, organize groups, resolve avoidance, and hand one Motion Frame to presentation.
AI Collaboration Notes
- AI-assisted work: reference-traffic evidence retrieval; UE5 road graph, dynamic routing, capacity reservation, signal scheduling, within-type ordering, pedestrian starvation protection, snapshot, and automated-test review.
- Important corrections: separated the HUD reference cost from authoritative route cost; confirmed that
IncidentPenaltydoes not enter the current formula; limited exit credit to one batch; distinguished shared Sequence from two-pass type arbitration; separated signal permission, reservation, actual occupancy, and P11 body execution; limited cross-table preflight to the Scheduling subsnapshot; confirmed 16 reroutes across the four-cycle soak. - Human judgment boundary: the synchronous small-graph search is not presented as the reference cross-frame global router, and integer capacity credit is not presented as a complete traffic-flow model.
- Verification: article claims were checked against
CyberTrafficOrchestrationDemoActor,CyberTrafficDynamicRoutingRuntime,CyberTrafficIntersectionSchedulingRuntime, the capacity-reservation runtime, six automated checks, and the Article 3 acceptance document. - Remaining risks: no time slicing for a large graph, capacity not bound to live Occupancy, lease duration not calibrated by road scale, same-session snapshot rather than durable save, and no complex-intersection or cross-region deadlock validation.
1 thought on “Urban Vitality P9 | UE5 Traffic Orchestration: Dynamic Routing, Capacity Gates, and Conflict-Zone Reservations”