Skip to content

Fix: use Random.Shared instead of new Random() per call#21

Merged
narayan24 merged 1 commit into
masterfrom
fix/random-shared
May 15, 2026
Merged

Fix: use Random.Shared instead of new Random() per call#21
narayan24 merged 1 commit into
masterfrom
fix/random-shared

Conversation

@narayan24
Copy link
Copy Markdown
Owner

Summary

  • RandomInt was creating new Random() on every call, which can produce identical sequences when called multiple times within the same system tick
  • Replaced with Random.Shared — thread-safe, properly seeded, and the idiomatic .NET 6+ approach

Effect

  • All random_int rolls in templates are now guaranteed to be independently random
  • Fixes the root cause of events appearing to never fire when multiple rolls occur in the same template evaluation

🤖 Generated with Claude Code

new Random() without a seed can produce identical sequences when called
multiple times within the same system tick. Random.Shared is thread-safe
and properly seeded, eliminating any chance of correlated rolls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@narayan24 narayan24 merged commit 6e266e8 into master May 15, 2026
@narayan24 narayan24 deleted the fix/random-shared branch May 15, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant