Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*, variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos: CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly. Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using RailEnterprise.Core.Common;
|
|
using RailEnterprise.Tests.Harness;
|
|
|
|
namespace RailEnterprise.Tests.Basics;
|
|
|
|
public static class RngTests
|
|
{
|
|
[Test(Description = "Vettore di riferimento di xoshiro256** con stato {1,2,3,4}")]
|
|
public static void Xoshiro256StarStarMatchesReferenceVector()
|
|
{
|
|
var rng = Rng.FromState(1, 2, 3, 4);
|
|
Assert.Equal(11520UL, rng.NextU64());
|
|
Assert.Equal(0UL, rng.NextU64());
|
|
Assert.Equal(1509978240UL, rng.NextU64());
|
|
Assert.Equal(1215971899390074240UL, rng.NextU64());
|
|
}
|
|
|
|
[Test]
|
|
public static void SameSeedGivesSameSequence()
|
|
{
|
|
var a = new Rng(42);
|
|
var b = new Rng(42);
|
|
for (int i = 0; i < 1000; i++) Assert.Equal(a.NextU64(), b.NextU64());
|
|
}
|
|
|
|
[Test]
|
|
public static void ForkIsStableAndDoesNotConsumeParent()
|
|
{
|
|
var root = new Rng(7);
|
|
var before = root.State;
|
|
var f1 = root.Fork("industries");
|
|
var f2 = root.Fork("industries");
|
|
var f3 = root.Fork("towns");
|
|
Assert.Equal(before, root.State);
|
|
Assert.Equal(f1.NextU64(), f2.NextU64());
|
|
Assert.NotEqual(new Rng(7).Fork("industries").NextU64(), f3.NextU64());
|
|
}
|
|
|
|
[Test]
|
|
public static void NextIntIsInRangeAndRoughlyUniform()
|
|
{
|
|
var rng = new Rng(123);
|
|
var counts = new int[10];
|
|
for (int i = 0; i < 100_000; i++)
|
|
{
|
|
int v = rng.NextInt(10);
|
|
Assert.True(v is >= 0 and < 10);
|
|
counts[v]++;
|
|
}
|
|
foreach (int c in counts) Assert.InRange(c, 9_500, 10_500);
|
|
}
|
|
|
|
[Test]
|
|
public static void NextDoubleIsInUnitInterval()
|
|
{
|
|
var rng = new Rng(99);
|
|
double sum = 0;
|
|
for (int i = 0; i < 100_000; i++)
|
|
{
|
|
double d = rng.NextDouble();
|
|
Assert.True(d >= 0 && d < 1);
|
|
sum += d;
|
|
}
|
|
Assert.Approx(0.5, sum / 100_000, 0.01);
|
|
}
|
|
}
|