Hacker News new | past | comments | ask | show | jobs | submit login

Strong agreement. xorshift or even a basic LCG work far better than Mersenne Twister. The only reason MT has persisted in the public consciousness for so long is because it has a memorable and cool name.



That sounds like a stretch. MT got its fame when LCG is the most popular PRNG in the world, and being the first popular PRNG that is measurably better than LCG did help. In fact the current "war" of PRNGs [1] hinders the adoption of both competing generators because MT is still good enough (in spite of its known throughput issue) and people doesn't like the choice.

[1] https://chasethedevil.github.io/post/war-of-the-random-numbe...


Yeah, I was making a Nixie tube clock with an STM32 and I was debating what I should use for my RNG...

I was trying to write a decent implementation for a LFSR PRNG and my friend was like fuck that, STM32 has a HW multiplier, just use an LCG and I wrote one from memory with like 2 lines. Just needed to grab the magic constants from wikipedia... (which I needed to anyway if I wanted to use an LFSR)

Strongly recommended, if you don't care about quality, LCG is simply unbeatable in terms of quick n dirtiness


Fun little bit of computer history: the Atari game "River Raid" (available on some flashback consoles) uses "randomly" generated landscapes and obstacles, but it's exactly the same every time you play it.

It uses the same seed on its LCG when you start the game, so everything else is deterministic. As far as I know it's the first procedurally generated video game.


"Pitfall" for the Atari 2600 uses the same approach for laying out obstacles, with a carefully tuned seed that produces a winnable game world with reasonable difficulty progression.

Another 2600 game, "Entombed", has seen recent enthusiasm for a novel automata which generates aesthetically pleasing and mostly-solvable mazes with a minimum of working memory.


Rogue is two years older than River Raid and also used procedural generation.


Which STM32 part? Some of them have a hardware RNG.


Yeah, but an LCG is easier ;P

And I used an STM32G031, which doesn't have one.


The large period is a certainly a desirable property when you are going to be drawing a few billion numbers.


It is also easy to port to different languages.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: