TerraTech

TerraTech

Not enough ratings
Random Number Generator (0 - 999)
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
115.551 KB
Nov 14, 2024 @ 5:00pm
1 Change Note ( view )

Subscribe to download
Random Number Generator (0 - 999)

Description
This circuit is a random number generator, generating random integers from 0 to 999.

The red block represents the output, while the green block represents the input which will decide when to activate a part of the circuit that increases randomness. It is recommended that it receives a button or single-tick input only once.

This RNG circuit is based off of the LCG (Linear Congruential Generator) algorithm, which calculates a random value based on the following equation:

next value = (multiplier * previous value + increment) mod modulus

It uses a multiplier and increment of 3 which is an odd and prime number and is small enough to avoid causing repetitiveness in the random value generation, and uses a modulus of 1000 to limit the output between 0 and 999. The input indicated by the green block leads to a one-second delay loop which allows a generated seed to override the current input (the previous value) for the LCG every second. The seed is generated by adding 97 (a prime number) to itself repeatedly, displaying the new seed, and using a modulus to reset at 1000.