Skip to content

feat: dice notation + pluggable random facade#76

Merged
tgiachi merged 2 commits into
mainfrom
develop
Jul 11, 2026
Merged

feat: dice notation + pluggable random facade#76
tgiachi merged 2 commits into
mainfrom
develop

Conversation

@tgiachi

@tgiachi tgiachi commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a new SquidStd.Game library and a random-number facade in SquidStd.Core.

SquidStd.Game (new)

  • DiceExpression — parses [N]dS[±M] notation, pure constants, and the dice(...) wrapper; Roll()/Roll(IRandom), Min/Max/Average, reusing the Core roll engine.

SquidStd.Core — Rng facade

  • IRandom abstraction (ints/longs/doubles, ranges, gaussian, NextBool(probability), NextBytes, Pick, Fisher–Yates Shuffle).
  • RandomFactory with thread-safe Shared and seeded/algorithm Create overloads; RandomAlgorithmType selects xoshiro256**/xoshiro128**/pcg32/splitmix64/mersenne-twister/chacha.
  • NRandomAdapter over NRandom 2.0.2 (non-cryptographic; crypto stays on CryptoUtils).
  • IWeightedList/WeightedList — O(log n) weighted selection for loot/spawn tables.

Tests

Full solution builds in Release; 64 new/updated tests green (algorithm reproducibility, ranges, gaussian mean, bool extremes, shuffle multiset, pick, weighted distribution, dice parsing + injected rolls).

tgiachi added 2 commits July 10, 2026 19:27
Introduce a new SquidStd.Game NuGet library that hosts game mechanics on top
of SquidStd.Core, keeping Core focused on infrastructure.

- feat(game): add DiceExpression (readonly record struct) parsing [N]dS[±M]
  notation, pure constants, and the wrapped dice(...) form; whitespace-tolerant
  and case-insensitive on the d separator
- feat(game): expose Min/Max/Average bounds and Roll() reusing the existing
  RandomUtils.Dice engine and BuiltInRng, so a fixed seed is reproducible
- feat(game): scaffold SquidStd.Game.csproj (PublishNuget, references Core),
  register it in SquidStd.slnx, and reference it from SquidStd.Tests
- test(game): cover parsing of all notation forms, invalid inputs (TryParse
  false / Parse throws), Min/Max/Average bounds, and Roll range + reproducibility
…election

Introduce a random-number facade in SquidStd.Core (SquidStd.Core.Rng) that
exposes multiple PRNG algorithms and gameplay helpers behind a SquidStd-owned
interface, so consumers never depend on the underlying NRandom types.

- feat(core): add IRandom abstraction (ints/longs/doubles, ranges, gaussian,
  NextBool with probability, NextBytes, Pick, Fisher-Yates Shuffle)
- feat(core): add RandomFactory with Shared (thread-safe) and seeded/algorithm
  Create overloads; RandomAlgorithmType selects xoshiro256**/xoshiro128**/pcg32/
  splitmix64/mersenne-twister/chacha
- feat(core): add NRandomAdapter wrapping NRandom generators; add NRandom 2.0.2
  package reference (non-cryptographic; crypto stays on CryptoUtils)
- feat(core): add IWeightedList/WeightedList for O(log n) weighted selection
  (loot/spawn tables) on cumulative weights over IRandom
- feat(game): add DiceExpression.Roll(IRandom) overload to roll from an injected
  reproducible source alongside the ambient BuiltInRng roll
- test: cover all algorithms (reproducibility, ranges, gaussian mean, bool
  extremes, shuffle multiset, pick), weighted distribution, and injected dice rolls
@tgiachi tgiachi merged commit b6f8fc8 into main Jul 11, 2026
2 checks passed
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