OSL Deterministic RNG - Replay & Lockstep View on Asset Store (opens in new tab)

Package details

Latest version
1.1.0
Last updated
First released
Unity version
6000.3.12 or later
Package size
86 KB
Files
27
Favorites
1
Views in the past week
8

Price tracking

Last checked
Tracked since
Lowest recorded
$7.99 on

Keywords

OSL Deterministic RNG - Replay & Lockstep

by OngsooLabs (opens in new tab)

No ratings yet

Released 1.1.0: a Unity deterministic RNG suite with versioned PCG32 snapshots, legacy-state migration, weighted gacha and pity, and replay/lockstep-friendly tests and samples.

Price $15.99

Buy on Asset Store (opens in new tab)

Affiliate link · Purchases support this site

Price history

Last 6 months

USD
Price history for OSL Deterministic RNG - Replay & Lockstep, 6 months Current $15.99; lowest $7.99; highest $15.99 in this period. $0 $10 $20 Jul Aug Sep Oct Nov Version 1.0.2 released 24 Aug 2026 v1.0.2 Version 1.1.0 released 2 Sep 2026

Asset preview

1 / 6

OSL Deterministic RNG - Replay & Lockstep screenshot 1

OSL Deterministic RNG - Replay & Lockstep screenshot 1

About this asset

OSL Deterministic Core is for Unity developers who need the same random sequence from the same seed and call order. It provides versioned PCG32 snapshots, independent streams, integer-first probability helpers, and tested gacha/pity building blocks for replay, lockstep-style samples, rollback state, and repeatable automated tests.

Release Status

- Repository package release: 1.1.0 (2026-09-01).

- Exported artifact: `OSL Deterministic Core 1.1.0.unitypackage`.

- Asset Store submission, review, approval, and public availability are separate from this repository release.

Why / Key Benefits

- Reproduce random decisions: Restore the 16-byte RNG state to replay the same sequence from a known point.

- Detect incompatible saves: Persist the algorithm ID and schema version with the state, and receive typed errors before an incompatible snapshot changes the engine.

- Migrate existing saves: Import the original unversioned 16-byte PCG32 state as legacy schema 0 and rewrite it as the current schema 1 envelope.

- Isolate gameplay systems: Derive independent streams for systems such as combat, loot, and AI so their call order does not interfere with one another.

- Build weighted rewards: Use cumulative weighted tables with a pluggable hard-pity policy.

- Reduce probability drift: Use integer-first dice, permille, percentage, and weighted selection helpers.

- Test repeatably: Run EditMode coverage for known sequences, state round-trips, distribution behavior, pity semantics, and the core RNG allocation path.

- Avoid third-party runtime dependencies: Use Unity 2021.3-compatible C#, built-in `JsonUtility`, and no third-party runtime packages or native plugins.

Typical Workflow

1. Create `OSLRandom` from a chosen seed and stream identifier.

2. Route gameplay random decisions through the provided RNG, shuffle, combat, or gacha APIs.

3. Use the raw 16-byte API for caller-managed transient buffers, or the JSON/Base64 versioned envelope for persisted saves and transport.

4. Restore the same compatible snapshot and replay the same input/call order to reproduce the random sequence.

Requirements

- Minimum Unity Version: Unity 2021.3 LTS

- Tested Unity Versions: Unity 2021.3.45f2 and Unity 6000.3.12f1 (58 Deterministic EditMode tests with matching snapshot golden vectors, plus package-isolation import and compile)

- Scripting runtime: .NET Standard 2.1

- Third-party runtime dependencies: None

Limitations / Scope

- The package makes its own RNG sequence reproducible; it does not make an entire Unity game simulation deterministic.

- Matching results require the same seed, stream, compatible algorithm and schema, RNG state, input data, and call order.

- Schema 1 readers reject unknown algorithms and future schema versions. A format change requires an explicit migration path rather than silent reinterpretation.

- Allocation tests cover the core RNG hot path. Constructing tables, collections, strings, or project-specific data can still allocate.

Documentation & Support

https://ongsoolabs.github.io/

From the publisher's Asset Store listing.

Technical details

- Algorithm: `PCG32` implements PCG-XSH-RR 64/32 and produces a reproducible sequence for the same initialized state and call order.

- Raw state: The existing engine API continues to write and restore a 16-byte little-endian state through caller-provided `Span<byte>` buffers.

- Versioned snapshot: `PCG32SnapshotEnvelope` adds the stable `pcg32-xsh-rr-64-32` algorithm ID, schema version 1, and the Base64-encoded 16-byte state. `PCG32SnapshotSerializer` captures and restores the envelope without changing the existing raw-state API.

- Encoding: Canonical compact JSON uses `algorithmId`, `schemaVersion`, and `stateBase64`. The transport Base64 helper wraps the complete UTF-8 JSON envelope, so algorithm and schema metadata are retained.

- Validation: Unsupported algorithms or schemas, malformed Base64, payloads that are not exactly 16 bytes, and even PCG32 increments raise `PCG32SnapshotException` with a typed `PCG32SnapshotError`. Restore validates the complete envelope before changing the target engine.

- Migration: New writes use schema 1. The original unversioned 16-byte state is treated as legacy schema 0 only through `FromLegacyState` or the 16-byte legacy branch of `FromBase64`; a successful migration is exposed through `SourceSchemaVersion` and `WasMigrated`, and the next serialization writes schema 1.

- Streams: Stream identifiers create independent PCG sequences that can separate combat, loot, AI, or other random consumers.

- Probability helpers: Dice, permille, percentage, shuffle, and weighted selection paths use integer comparisons for their random decisions.

- Gacha: `OSLGachaTable` uses cumulative weights and binary search. `IPitySystem` is the extension point, with `SimpleHardPity` providing a configured forced-drop threshold.

- Allocation scope: Tests cover the core RNG hot path as a best-effort zero-allocation check. Object construction and collection-based APIs are outside that guarantee.

- Sample: The Lockstep Demo runs two instances with the same seed and inputs and compares an FNV-1a state hash each tick. **Inject DESYNC** consumes one extra RNG value on the right side, proves that the hashes diverge, and uses **Reseed** to demonstrate recovery. It demonstrates the included sample, not whole-game deterministic simulation.

- Release verification: Repository package release 1.1.0 (2026-09-01) has a matching registry, manifest, and dated Changelog. The exported `OSL Deterministic Core 1.1.0.unitypackage` contains 27 assets: 23 Deterministic assets and 4 shared Core assets; Tests are excluded.

- Compatibility verification: The same literal PCG32 draws, state Base64, canonical JSON, and whole-envelope Base64 pass the 58 Deterministic EditMode tests in Unity 2021.3.45f2 and 6000.3.12f1.

Compatibility

Render pipelines supported in each Unity version
Unity version Built-in URP HDRP
6000.3.12f1 Compatible Compatible Compatible

This package consists entirely of pure C# logic and does not contain any materials, shaders, or rendering components. Therefore, it is completely independent of any rendering pipeline and works flawlessly out-of-the-box with Built-in, URP, and HDRP.

As listed on the Asset Store.