Remix.run Logo
raphar 2 hours ago

Please show the game list in random order, or starting in a random position. Just to promote the discovery of the games later in the alphabet. (Or end up with games called ______11_roguexxx, lol)

susam 2 hours ago | parent [-]

Indeed. This is precisely what we did for the HN Personal Websites Directory at <https://hnpwd.github.io/>. The website info cards are shown in random order, with the ordering reshuffled every hour.

I am not a professional web developer but I have been using JavaScript since 2001 or so. It is only this month that I realised JavaScript does not have a way to seed the pseudorandom number generator (PRNG). So there was no way to do something like:

  srand(Math.floor(Date.now() / 1000 / 3600))
As a result, I had to implement a linear congruential generator (LCG) based on the Knuth parameters: <https://github.com/hnpwd/hnpwd/blob/1e513b1/web/script.js>. When I first came across the LCG algorithm (in K&R with different parameters) in the early 2000s, I felt it was neat but assumed I would never need it, since almost every mainstream language comes with a reasonable PRNG. Little did I know back then that the most ubiquitous language on the web would make that old knowledge useful again, some 25 years later.