User Tools

Site Tools


base:comparison_of_6502_random_generators

Comparison of 6502 pseudo random generators

This is an overview of the main properties of eight algorithms here on codebase.

Each algorithm was implemented as stated in the linked articles. Code size, execution time was measured. Execution times do not include the RTS command. Many PRNGs have a problem when the internal state becomes 0. Since this might be an important feature, it was stated which algorithms can also eventually output and handle a 0.

The quality was assessed by a test if the low byte hits all 256 numbers for 2000 random numbers and by a graphical check of the plot of 51200 random values. In every line n, the n&7-th bit of the result was plotted. For the results annotated with high quality, I could not identify any patterns in the plot. For good quality, some slight patterns or imbalances were visible. For low quality a direct repetition of values was visible.

result size execution cycles size (bytes) seeding quality plot
798 Xorshift 16bit 30 21 all except 0 high
X ABC 16bit 38 28 risk of short cycle high
Whiteflame16 16bit 30* 35 all values medium (some horizontal dashes visible)
Galois LFSR 32bit 60 50 all except 0 medium (too many 0s)
Two16 PRG LSFR 16bit 108 66 all except 0 high
another 16bit PRG 16bit 30 21 all except 0 low
16bit PRG 16bit 69 49 all except 0 low
Whiteflame8 8bit 16* 14 all values, 0-255 low
AX+ Tinyrand8 8bit 18 15+ all values, 0-255 high

* implementation has branches, execution time varies
+ not including separate 13 byte function for setting an 8bit seed

base/comparison_of_6502_random_generators.txt · Last modified: 2021-11-28 00:15 by wil