News for hackers. Stuff that matters.
Re:“A calculator app? Anyone could make that” by readyplayernull on Sunday February 16, 2025 @12:16PM (#43069647)
Thanks!! I've been looking for an algo to draw pixel positions in a pseudorandom way only once. I didn't know a way to do it without storing and shuffling all positions. Now, I only need to draw a centered filled circle, so there might be a prime number for it, and even if the prime only does it for a given amount of points, I could switch to other primes until the circle is filled, and get an optimal and compressed single-visit scattering algo.
Re:“A calculator app? Anyone could make that” by meindnoch on Sunday February 16, 2025 @12:49PM (#43069981)
Mind you, placing many pixels at coordinates from a linear congruential generator will not look random at all.
Re:“A calculator app? Anyone could make that” by satvikpendem on Sunday February 16, 2025 @01:07PM (#43070110)
Have you seen this algorithm for dithering? Reminds me of your problem.

https://news.ycombinator.com/item?id=42808889

Re:“A calculator app? Anyone could make that” by readyplayernull on Sunday February 16, 2025 @01:13PM (#43070158)
Yes, but another requirement is the algo to be very fast, and dithering takes way more operations than the proposed Fermat PRNG.
Re:“A calculator app? Anyone could make that” by bazzargh on Sunday February 16, 2025 @04:24PM (#43071854)
this is something you should read https://extremelearning.com.au/unreasonable-effectiveness-of... (it's effectively the fermat prng described, but goes into more depth)