Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Digital Logic Sim

​A minimalistic digital logic simulator · By Sebastian Lague

RNG

A topic by virtual_matt created 43 days ago Views: 340 Replies: 5
Viewing posts 1 to 6

I just noticed it would be nice to have a random number generator. I know I could just use a clock, a binary counter and an algorithm like LCG, but the seed clock runs the same way as the cpu clock so it isn't really random. There are some cases, where it's obviously dependend on the instruction the cpu is currently working on. Do you think the same?

i have a rng chip, 2 of them. they work by having the output of a multiplier conect to adders that feeds the multiplier inputs. it can go on forever, 




That could work! My idea was that I could use a new seed every clock cycle, which the CPU than uses to create a random number with a software algorithm, but that's a good solution. Thank you.

(1 edit)

No, wait. It might be a problem for my application, that it always gives the same sequence of numbers. So whenever my CPU wants to have a random number at a specific line in the program it gets the same number every time. For example if it requests a number at the first cycle, it gets the number 3. (0 * 13 + 3)

use a shifter for some real randomness!

Yeah, I mean something like a independent clock would be nice anyway, because you could create randomness and timing. Independently of your clock, that controls randomness or clock speed that ruins time in your game in any way.