Incremental & reversible chaos library. Generates pseudo-random numbers (not suitable for cryptographic or statistical applications) in a reversible and incremental manner.
Capabilities include:
The core API is available in C, Python, Javascript, and Unity/C#, and includes:
prng
and rev_prng
the forward and reverse PRNG functionslfsr
as a simple non-reversible PRNG (Linear Feedback Shift Register)udist
, idist
, and expdist
for floating-point, integer-range, and floating-point exponential distributions (only in Python and Javascript for now).cohort_shuffle
and rev_cohort_shuffle
for finding shuffled/unshuffled indices one-at-a-time.distribution_portion
- For N items distributed among K segments each of maximum size S, how many items are in segment k?distribution_prior_sum
- For N items distributed among K segments of maximum size S, how many of the items are in segments that preceed segment k?distribution_segment
- For N items distributed among K segments of maximum size S, which segment does item n get distributed to?Full documentation for all core functions pulled directly from the Python implementation (applies to all implementations):
Example code using the JavaScript implementation that demonstrates things to do with the library.
The unity/anarchy
folder is a complete Unity project which includes a component implementation of the library and a simple demo component that uses it to shuffle tiles in a Tilemap
. When it’s running, you can left-click to advance to the next seed, or right-click to go back to the previous seed. The code in the Tilepicker
component demonstrates how to use anarchy
.
That said, I’m not a Unity expert and this probably isn’t the right way to release the library; it seems like a plugin would be more appropriate, but I haven’t yet figured out the details of building and deploying one. If you’d like to use anarchy more seriously in a Unity context, let me know (even just by opening an issue) and I can make that more of a priority.