Something is wrong with this PRNG, it uses a large (65536 bit) pool of bits from which randomness is extracted in sets of 256 bits, what seems to fail is the bit storage feature (ests,sts,lts,elts) which is meant to store randomness from each stage and mix it back in later. It starts with a seed (l) and in every stage: 1) passes l through the mixing function (m) 2) takes some bits from storage and sends others into storage 3) passes l through the mixing function (m) 4) takes a copy of l, then tweaks the copy (t), mixes it (m) and squeezes bits out of it There are 4 storage lists: 1) ests (extra short term storage) takes blocks of 3840 bits and keeps them for 16 stages. 2) sts (short term storage) takes blocks of 240 bits and keeps them for 256 stages. 3) lts (long term storage) takes blocks of 15 bits and keeps them for 4096 stages. 4) elts (extra long term storage) takes blocks of 1 bit and keeps them for 61440 stages. The mixing function (m) works by running the list through 256 stages each consisting of of 256 steps of rule 30 followed by writing the list in 256 rows and reading it in columns.
m[x_] := Nest[ Flatten[Transpose[ Partition[Flatten[CellularAutomaton[30, #, {{256, 256}}]], 256]]] &, x, 256] t[x_] := 1 - x s[x_] := Table[Mod[Total[Partition[x, 256][[i]]], 2], {i, 1, 256}] f[list_, store_, a_, b_] := {Join[list[;; a - 1], store[[;; (b - a) + 1]], list[[b + 1 ;;]]], Join[Drop[store, (b - a) + 1], list[[a ;; b]]]} l = Normal[SparseArray[{1}, 65536]]; k = {}; ests = Normal[SparseArray[{}, 61440]]; sts = Normal[SparseArray[{}, 61440]]; lts = Normal[SparseArray[{}, 61440]]; elts = Normal[SparseArray[{}, 61440]]; Do[l = m[l]; {l, ests} = f[l, ests, 61441, 65280]; {l, sts} = f[l, sts, 65281, 65520]; {l, lts} = f[l, lts, 65621, 65535]; {l, elts} = f[l, elts, 65536, 65536]; l = m[l]; AppendTo[k, s[m[t[l]]]], {256}]
Aucun commentaire:
Enregistrer un commentaire