feat(rng-seam): IRandomSource interface + RandomSourceBridge arithmetic
Adds the RNG seam skeleton (Task 1 of M12): IRandomSource (NextUnit/NextSelf) and RandomSourceBridge.Range mirroring BattleManagerBase.StableRandom exactly (`(int)Math.Floor(val * unit)`). RngSeamTests pins the floor arithmetic (1 test, passing). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
SVSim.BattleEngine.Tests/RngSeamTests.cs
Normal file
21
SVSim.BattleEngine.Tests/RngSeamTests.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using SVSim.BattleEngine.Rng;
|
||||
|
||||
namespace SVSim.BattleEngine.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class RngSeamTests
|
||||
{
|
||||
// RandomSourceBridge.Range must mirror the engine's exact roll arithmetic:
|
||||
// BattleManagerBase.StableRandom does `(int)Math.Floor((double)val * unit)`.
|
||||
[Test]
|
||||
public void Bridge_Range_mirrors_engine_floor_arithmetic()
|
||||
{
|
||||
Assert.That(RandomSourceBridge.Range(7, 0.0), Is.EqualTo(0)); // floor(7*0) = 0
|
||||
Assert.That(RandomSourceBridge.Range(7, 0.999), Is.EqualTo(6)); // floor(6.993) = 6 (never == val)
|
||||
Assert.That(RandomSourceBridge.Range(3, 0.5), Is.EqualTo(1)); // floor(1.5) = 1 (middle of 3)
|
||||
Assert.That(RandomSourceBridge.Range(1, 0.5), Is.EqualTo(0)); // floor(0.5) = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user