mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
Separated deposit chance samples
- Clump seeds mix the generator seed and attempt index before sampling - Deposit plans share immutable seeds across preparation workers - Probability checks cover generator independence and adjacent clumps across batch boundaries
This commit is contained in:
1 parent
0bfb4d6718
commit
723426177c
4 files changed
+48
-8
No files matched your search
@@ -37,7 +37,6 @@ import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -103,7 +102,6 @@ public class IrisDepositModifierContextTest {
|
||||
RNG rng = mock(RNG.class);
|
||||
when(rng.d()).thenReturn(0.5D);
|
||||
when(rng.i(0, 5)).thenReturn(4, 0);
|
||||
when(rng.nextParallelRNG(anyLong())).thenReturn(rng);
|
||||
|
||||
new IrisDepositModifier(engine).generate(generator, null, null, rng, 0, 0, false, null);
|
||||
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class IrisDepositModifierOrderingTest {
|
||||
RNG generatorRng = new RNG(0L).nextParallelRNG(0L);
|
||||
for (String name : List.of("dimension", "region", "biome")) {
|
||||
for (int i = 0; i < 25; i++) {
|
||||
expectedSamples.add(name + ":" + generatorRng.nextParallelRNG(i + 1L).getSeed());
|
||||
expectedSamples.add(name + ":" + IrisDepositModifier.clumpSeed(generatorRng.getSeed(), i));
|
||||
}
|
||||
}
|
||||
Collections.sort(expectedSamples);
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class IrisDepositModifierProbabilityTest {
|
||||
@Test
|
||||
public void generatorAndClumpChancesRemainIndependent() {
|
||||
int samples = 100_000;
|
||||
int accepted = 0;
|
||||
for (int seed = 0; seed < samples; seed++) {
|
||||
if (new RNG(seed).d() <= 0.2D
|
||||
&& new RNG(IrisDepositModifier.clumpSeed(seed, 0)).d() <= 0.2D) {
|
||||
accepted++;
|
||||
}
|
||||
}
|
||||
assertEquals(0.04D, accepted / (double) samples, 0.003D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void neighboringClumpChancesRemainIndependentAcrossBatchBoundaries() {
|
||||
int samples = 100_000;
|
||||
for (int first : new int[]{0, 7, 31}) {
|
||||
int accepted = 0;
|
||||
for (int seed = 0; seed < samples; seed++) {
|
||||
if (new RNG(IrisDepositModifier.clumpSeed(seed, first)).d() <= 0.2D
|
||||
&& new RNG(IrisDepositModifier.clumpSeed(seed, first + 1)).d() <= 0.2D) {
|
||||
accepted++;
|
||||
}
|
||||
}
|
||||
assertEquals("Clump pair at " + first, 0.04D, accepted / (double) samples, 0.003D);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user