Skip to content

IRobustRandom refactor.#6454

Open
moonheart08 wants to merge 22 commits intospace-wizards:masterfrom
moonheart08:13-03-2026-robustrandom-api-improvements
Open

IRobustRandom refactor.#6454
moonheart08 wants to merge 22 commits intospace-wizards:masterfrom
moonheart08:13-03-2026-robustrandom-api-improvements

Conversation

@moonheart08
Copy link
Contributor

@moonheart08 moonheart08 commented Mar 13, 2026

Migrates a bunch of implicitly defined functions on IRobustRandom to be extension methods instead, adds some new static constructors for ease of use, deprecates SetSeed, adds a new marker interface for "this mustn't be the global randomizer", all while keeping content compatibility*

Technical reasoning

Extension methods

Methods defined on interfaces cannot be called on concrete types. While this isn't a problem yet, it will be when I introduce a concretely typed, serializable randomizer.

Interface-level static constructors

This is to allow us to change implementations down the line, RobustRandom's internals rely on System.Random, which has a bunch of flaws for our usecase (including poor rng properties when seeded)

*if the content PR is merged.

@moonheart08 moonheart08 changed the title Clean up IRobustRandom slightly. IRobustRandom refactor. Mar 14, 2026
@Tayrtahn Tayrtahn added the T: Refactor Type: Code refactor label Mar 15, 2026
moonheart08 and others added 3 commits March 15, 2026 08:53
Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
Copy link
Member

@slarticodefast slarticodefast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves #5995 since the System.Random implementation of NextFloat does not have that problem. We just have to make sure not to reintroduce it if we want to replace System.Random.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T: Refactor Type: Code refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants