Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e52e190

Browse files
Add dump_seed_aray
1 parent fe917f0 commit e52e190

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎csharp_rand.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __call__(self, vec):
3737

3838
class csharp_rand:
3939
sa = {
40+
-56: rand_vec(0, 0), # SeedArray[0] is unused?
4041
-55: rand_vec(995627988, 1440537475),
4142
-54: rand_vec(2027951972, 765327687),
4243
-53: rand_vec(670659949, 2146736586),
@@ -98,6 +99,7 @@ def sample_equation(self, rand_i: int) -> rand_vec:
9899
"""
99100
What constants are needed to produce the `i`th PRNG from Random?
100101
"""
102+
assert rand_i >= -56
101103
if ret := self.sa.get(rand_i, None): # try from cache
102104
return ret
103105

@@ -114,6 +116,13 @@ def sample(self, seed, i) -> int:
114116
def inv(self, rand, i) -> int:
115117
return self.sample_equation(i).invert().resolve(rand)
116118

119+
def dump_seed_array(self, seed):
120+
for i in range(0, 56):
121+
myind = i - 56
122+
val = self.sample(seed, myind)
123+
print(f"SeedArray[{i}]: {val}")
124+
125+
117126

118127
def test_rand():
119128
import json

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /