Recent

Author Topic: PRNG: Why transition to Xoshiro128?  (Read 3232 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6390
Re: PRNG: Why transition to Xoshiro128?
« Reply #15 on: September 22, 2023, 09:22:16 am »
Warfley, you store different RNGs with serializable states with the chest and the monster as part of their creation, and use them for related events. UnityEngine.Random both provides serializable Random.state and suggests switching to System.Random for “multiple independent random number generators”.

So the chest etc. carry around their own generator polynomial plus the current value. However IMO you'd be better treating this as a crypto exercise, since encryption /by/ /definition/ generates a repeatable result while random number generation /by/ /definition/ produces a result that passes various tests of randomness.

I sympathise with the "this is a Mersenne RNG so will generate a known test sequence" argument and its extension that test runs of a program should be reproducible, but this shouldn't be stretched to areas where it's not really applicable.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Thaddy

  • Hero Member
  • *****
  • Posts: 13285
Re: PRNG: Why transition to Xoshiro128?
« Reply #16 on: September 22, 2023, 09:59:24 am »
The prng's in Freepascal made me so angry that I already wrote a couple of years ago:
a: Thread safe randoms
b: Delphi compatible random
c: A 100% compatible Mersenne twister that is thread safe.
d: All of Marsalia et al code into Pascal

Although the core team are mostly computer scientists! they know jack shit about keeping data compatibility for statistical use. They simply do not understand that changing PRNG switches unavoidably breaks data sets.

All my code can be found on this forum, the wiki and on Rosetta code.

In general, the newer PRNG has a better distribution compared to the old one, it is also faster.

But in general a PRNG should be pluggable, like in C11 or higher. Just because of statistics.
« Last Edit: September 22, 2023, 10:04:57 am by Thaddy »
I actually get compliments for being rude... (well, Dutch, but that is the same)

runewalsh

  • Jr. Member
  • **
  • Posts: 73
Re: PRNG: Why transition to Xoshiro128?
« Reply #17 on: September 22, 2023, 10:27:32 am »
So the chest etc. carry around their own generator polynomial plus the current value.
No, they carry around the state of the RNG (4 uint32s in the case of Xoshiro128**).

Thaddy

  • Hero Member
  • *****
  • Posts: 13285
Re: PRNG: Why transition to Xoshiro128?
« Reply #18 on: September 22, 2023, 10:51:29 am »
Correct. Also note that you imply the unsigned.. 8) which is even more correct.
I actually get compliments for being rude... (well, Dutch, but that is the same)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6390
Re: PRNG: Why transition to Xoshiro128?
« Reply #19 on: September 22, 2023, 12:06:10 pm »
No, they carry around the state of the RNG (4 uint32s in the case of Xoshiro128**).

Which assumes that the RNG is provided by the RTL, which in that sort of case is clearly undesirable.

My preference would be for the RNG to be provided by e.g. an LFSR, with coefficients and state carried around by the object.

However as I've said, a crypto approach would be better.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Kays

  • Hero Member
  • *****
  • Posts: 546
  • Whasup!?
    • KaiBurghardt.de
Re: PRNG: Why transition to Xoshiro128?
« Reply #20 on: September 23, 2023, 10:58:40 am »
Because in the end there is no reason to discuss it.
Where is this doctrine codified?
The PRNG behind Random is an implementation detail and it's documented as such. […]
This is certainly an argument that changing the implementation is not forbidden. It is not an argument that this change must occur.
[…] I like meaningless improvements and persuading the people to apply them with fancy scientific papers. […]
I’m afraid it is meaningless noise indeed. If there was a codified design principle the RTL must be as lightweight as possible, I could understand the motifs, why this implementation is an improvement. Otherwise I anticipate in ten years from now we’ll change the PRNG implementation again.
[…] Wirth's hack that the control variable has an undefined value after a FOR loop is one of the worst things he did, […]
Minor correction: The utilized control variable does not have an undefined state after a for-loop statement is executed. It just has the state prior evaluation of the for-statement commenced. In other words, the control variable does not get defined by the for-statement.
Yours Sincerely
Kai Burghardt

MarkMLl

  • Hero Member
  • *****
  • Posts: 6390
Re: PRNG: Why transition to Xoshiro128?
« Reply #21 on: September 23, 2023, 02:40:15 pm »
[…] Wirth's hack that the control variable has an undefined value after a FOR loop is one of the worst things he did, […]
Minor correction: The utilized control variable does not have an undefined state after a for-loop statement is executed. It just has the state prior evaluation of the for-statement commenced. In other words, the control variable does not get defined by the for-statement.

My recollection is that Wirth explicitly said it did not have a defined value, however that might depend on the edition of J&W being consulted.

I believe that somebody earlier in the thread highlighted different behaviour from different compilers.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018