4. Precedents: what game engines already know
Few kinds of software are as complex, or as fast, as a modern game. Within one frame, 16.7 ms at sixty frames per second, an engine simulates physics, animates characters, runs their AI, mixes audio, replicates state to remote players and renders the scene. A large game is built by hundreds of people, and most of them do not write C++: designers, animators, technical artists and sound designers change the game every day. This section asks how such software is organised. Its organisation is the closest working precedent for what RG proposes, and the engines arrived at it before language models could write code. Unreal Engine is our main example. Section 4.5 returns to the other systems named in Section 1.
4.1 Unreal Engine: a typed core, reflection and graphs#
Unreal Engine 4 was released in March 2014 [325], with Blueprints as its visual scripting system [110]. Blueprints succeeded Kismet, in which designers of Unreal Engine 3 wired sequences of actions to game events [128], and the Blueprint compiler still carries Kismet’s name [113]. Five layers make up the result.
A native core#
The engine, and the parts of a game that must be fast, are written in C++. Rendering, physics, animation evaluation, networking and the inner loops of gameplay run there.
Reflection#
Programmers annotate C++ declarations with macros: UCLASS for a class, UPROPERTY for a property and UFUNCTION for a function. The Unreal Header Tool parses the annotations and generates reflection code [124]. One declaration then serves many consumers: garbage collection, serialization, the editor’s property panels, run-time type information, network replication and Blueprints. Specifiers on each declaration decide what Blueprints may do with it: BlueprintCallable exposes a function to graphs, BlueprintImplementableEvent lets a Blueprint supply a function’s body, and BlueprintReadWrite exposes a property for reading and writing.
Blueprints#
A Blueprint is a graph of nodes with typed pins [114]. Execution pins order the nodes that have effects. Data pins carry values, and their wires are typed: the editor refuses a wire between incompatible pins. Pure nodes have no execution pins and are evaluated when a node that reads them runs. A Blueprint class can derive from a C++ class, so designers extend what programmers expose; C++ can also declare events whose bodies a Blueprint supplies. The Blueprint compiler turns a Blueprint into a generated class, merges its event graphs into one, and emits bytecode for the engine’s script virtual machine [113]. Unreal Engine 4 could also generate C++ from Blueprints when cooking, to remove the virtual machine’s overhead; Unreal Engine 5 removed that option [109, 121]. Figure 5a shows a small event graph.
Many graph languages, one object model#
Materials are expression graphs translated to HLSL and compiled into shaders [120]. Animation has blend graphs and state machines. AI has behaviour trees and StateTree, a hierarchical state machine that combines the selectors of behaviour trees with states and transitions [126]. Visual effects, audio and procedural content have graph editors of their own. Each language has its own semantics (dataflow, state machine, tree), and all of them share one reflected object model, one asset system and one editor.
A runtime built for scale#
Several subsystems carry the load when a world grows:
MassEntity, a framework for data-oriented computation, stores data-only fragments grouped by archetype in chunks and runs stateless processors over them [119].
Replication starts from a server that holds the authoritative state. Properties marked for replication are pushed to clients, remote procedure calls are marked reliable or unreliable, and relevancy, decided per connection, determines what each client receives [125].
The Gameplay Ability System gives an actor a component that holds its granted abilities, its gameplay tags and its attributes, and applies effects that change attributes and tags in a way compatible with network prediction [116].
World Partition keeps one persistent level, divided into grid cells that stream in and out by distance [127]. With One File Per Actor, each actor is saved in its own file, which reduces contention for source-control locks [122].
Tools over the same model#
The Asset Registry indexes assets, including those not loaded, together with their dependencies, and the Reference Viewer draws the resulting graph [111]. Unreal Insights records trace events, selected by channel, for live or later analysis [117]. Live Coding rebuilds C++ and patches it into the running editor or game on desktop platforms [118].
Figure 5a. A Blueprint event graph, redrawn. Thick wires carry execution and order the impure nodes; thin wires carry data and are typed by colour; the pure nodes have no execution pins. The variable and the event come from a C++ class through reflection.
Figure 5b. The same rule in RG. Execution becomes a Transition inside an exclusive component, data becomes Bind and Channel, and a replicated property becomes a signal. Orange marks what a graph of one game process cannot state: the Session to a service in another place, its grant, and a claim checked by TLC.
Figure 5. Blueprints and RG side by side. The precedent supplies typed pins, the split between execution and data, and a native core behind reflection; RG keeps them and extends the graph past the boundary of one process.
4.2 Why it works#
Five decisions explain why this organisation produces software that is both complex and fast.
Composition is separate from computation. Graphs compose and the native core computes. Epic advises keeping heavy and frequent work in C++, and its programmers turn complex Blueprint logic into new C++ nodes [115]. The graph’s overhead is then paid per event rather than per entity.
Types sit at the pins. The editor rejects a wire between incompatible pins. People who do not program can therefore compose with less risk: a class of errors moves from run time to edit time, although a graph can still fail at run time in other ways.
One reflected model serves every tool. The editor, the serializer, the garbage collector, the network layer, the profiler and the cooker read the same metadata, so they agree with one another.
Effects are ordered explicitly; data flows implicitly. Execution wires fix the order of effects. Pure data is computed on demand.
Iteration is fast. An edit compiles in seconds, the game runs inside the editor, and Live Coding patches native code without a restart.
Blueprints are the gold standard for what RG attempts. Epic shipped them in 2014, years before language models could write code. Their users were mixed teams of designers, artists and programmers. Their lesson is that a typed graph over a native core lets people with different skills change one complex, fast system while a class of errors is caught before the game runs. Agents built on language models are one more kind of collaborator with the same need: they also work best on typed, checkable units with immediate feedback (Section 19).
4.3 Where the analogy stops#
Blueprints describe one game. A multi-runtime system needs more.
One process, one world. A Blueprint describes behaviour inside one game process, and replication extends its state to the clients of that game. Matchmaking, accounts, stores, telemetry pipelines, analytics and live operations run outside the engine, in other languages and tools, with no shared model. That outside is the subject of this paper.
Changes are files. Blueprints and levels are binary assets. They cannot be merged as text, so source control locks them on checkout [123], and Epic’s own guidance notes that C++ is easier to diff and merge because it is text [112]. One File Per Actor exists to reduce the resulting contention [122]. In RG the unit of change is the element, and patches that touch different elements commute and merge (Theorem 10).
The implementation is the semantics. A Blueprint means what its virtual machine does. There is no specification to check, no claim that goes stale when code changes, and no notion of an effect whose outcome is unknown.
Authority is coarse. Who may change what is a matter of file permissions and review practice. There are no grants on elements and no rule that separates proposing a change from approving it.
Graphs do not scale without limit. Large event graphs are hard to read, and they run more slowly than native code [115]. RG keeps graphs at the level of composition (components, connections and places) and leaves algorithms in code.
Two execution paths are expensive. Nativization gave Blueprints a second path, through generated C++, and Unreal Engine 5 removed it [109]. RGL also has two paths, the generic runtime and specialised regions, and tests their equivalence by running one conformance suite on both (Section 10.7).
Other engines show the same pattern. Unity added visual scripting and a data-oriented entity system [341, 342]. Godot removed its visual scripting language from Godot 4 [225]. Our reading is that visual graphs succeed where they compose a strong, typed core, and struggle where they duplicate a general-purpose language without one. RG is designed to be the first kind.
4.4 From Blueprints to RG#
Table 2 maps each idea above to its counterpart in RG and states what RG adds. Figure 5b draws the event graph of Figure 5a in RG notation. Execution becomes a Transition, data becomes Bind and Channel, and the replicated health value becomes a signal. The figure then continues past the game process, where no engine graph reaches: a Session to a leaderboard in another place, the grant that permits it, and a claim checked by TLC.
| In Unreal Engine | In RG | What RG adds |
|---|---|---|
| C++ core behind reflection; the Unreal Header Tool | Kotlin and C++ bodies behind ports; symbol processing and the K2 plugin extract contracts (Section 13.4) | contract fingerprints that hold across runtimes |
| Typed pins; wires checked in the editor | typed ports; W3–W5 in the IDE and workbench | hyperedges with several parties and roles |
| Execution pins versus data pins; pure nodes | Transition versus Bind and Channel; the pure profile | durable transitions; sessions with outcomes |
| A Blueprint class extends a C++ class | a graph-owned scope over source-owned components | DPO patches; mounting at boundaries (Corollary 4) |
| Graph languages for materials, animation, AI, audio and procedural content | profiles, derived kinds and domain modules over | one signature; traversals shared by all domains |
| Blueprint compiler and virtual machine; materials compiled to shaders | graph-owned regions compiled to Kotlin; traversals compiled into stores | optimisation with the whole graph (Section 10.7) |
| Replication: authority, replicated properties, reliable and unreliable calls, relevancy | exclusive components with epochs; signal channels with QoS; sessions; interest as a traversal | fencing at stores that check epochs; effect identity elsewhere |
| Gameplay Ability System: granted abilities, gameplay tags | Grants, labels and facets | no self-approval (A5); label flow (W11) |
| Mass Entity: fragments, archetypes, processors | the columnar kernel (Section 11) | the system graph stored the same way |
| World Partition: streamed cells; a file per actor | regions and keyed places; one row per element | patches that commute and merge |
| Asset Registry: dependencies for cooking and chunks | impact and closure traversals | closures across runtimes; code push |
| Unreal Insights: trace channels | Observations joined by identity | coverage claims |
| Live Coding | region release (Section 9.5) | admission, fencing and rollback |
4.5 Other precedents#
Kubernetes#
The API server stores typed objects with a desired specification and an observed status. Controllers are control loops that move the current state towards the desired state. Custom resource definitions add new kinds with schemas; operators package the operational knowledge of one application as controllers; admission controllers and webhooks validate or modify an object before it is stored [335, 336, 337, 338]. RG takes the open schema, reconciliation and admission. It adds typed relations where Kubernetes has labels and selectors, transactions over many objects, and semantics past the boundary of the container.
Actors#
Hewitt’s actors, Erlang/OTP and Orleans [20, 34, 169] give isolation, mailboxes, supervision trees and, in Orleans, activation on demand by identity. RG keeps each of these as a profile, a family or a facet. It rejects one actor idea: location transparency. A Bind never crosses a place, because a remote call fails and waits in ways that a local one does not (Section 6). The handover model also shows that actors need fencing at the stores they write (Table 34).
TLA#
TLA describes a system as a state machine, composition as conjunction and implementation as refinement [214], and it has been used on production designs at AWS [264]. RG generates specifications per family and region from the graph that the runtime executes, so the model and the system share one source. What can still diverge is a body that does not keep its contract, which tests and observations check.
Statecharts and Stately#
Harel’s statecharts add hierarchy, orthogonal regions and history to state machines [163], and SCXML standardises their execution [28]. XState implements statecharts and actors in TypeScript, and Stately provides a visual editor for such machines [320]. RG’s routes and durable transitions are statecharts (Figure 13), and a graph-owned scope can likewise be edited visually or as text. What RG adds is that the machine is connected: its transitions call sessions, emit on channels and act under grants, all in one graph.
React and Compose#
React and Compose made an interface a function of state, reconciled by identity: React by key, Compose by position in the composition, with optional keys [149, 242]. Compose also showed that a compiler plugin can deliver a programming model while the source stays ordinary Kotlin, and RGL’s plugin follows it (Section 10.7). RG makes keyed reconciliation the meaning of its whole runtime layer, not only of the interface (Section 8.4).
Agent graphs#
LangGraph runs long-running, stateful agents as graphs that mix deterministic steps with steps taken by a model, and offers durable execution and human-in-the-loop control [217]. It is a recent precedent for treating agent behaviour as a durable, inspectable graph. RG places such graphs inside the rest of the system, under grants and labels (Section 17.1).
4.6 What RG takes, and what it adds#
From Unreal Engine, RG takes a typed graph over a native core, the split between execution and data, one reflected model for every tool, and data-oriented runtimes. From Kubernetes it takes desired and observed state, reconciliation, an open schema and admission. From actors it takes isolation, mailboxes, supervision and activation by identity; from TLA, specification, refinement and model checking; from statecharts, hierarchy and history, and one model in visual and textual form; from React and Compose, keyed reconciliation and a compiler plugin as the carrier of a programming model. Each precedent is deep in one domain and stops at its edge: the engine at the game process, Kubernetes at the container, actors at the mailbox, TLA at the model, statecharts at the machine, React at the screen. RG joins them in one typed graph, so that the guarantees each one provides can be stated, and checked, across the boundaries between them as well.