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

I've done three worth mentioning.

One is GenFortune: https://github.com/EternityForest/GenFortune Which is like fortune, but it generates them using a MadLibs style algorithm from data files.

One is a candle flicker simulation algorithm. I did not make this demo, I wrote the original for the PIC, they adapted a version of it for JS: http://blackdice.github.io/Candle/

At the time cheap LED candles weren't very good, but it seems many are a lot better now. I used a model assuming that the flickering was wind driven, that the flame always wants to rise towards it's maximum at a certain rate, but that depending on the current wind speed at any time it can get randomly "toppled" to a lower value, while then wind settles down to a baseline but can randomly jump up in a gust to a higher speed.

Of course, now we have multicolor multipixel flame algorithms that do way better, but this is pretty good on a single pixel light.

I still use mostly the same algorithm for DMX flame effects in Python, but I apply then effect less to the red channel so it gets redder when the light goes down for a little added variety.

The other is this RNG. It does not even have a full period for it's 32 bits of state but it's very fast on PIC10 type chips. I can't think of any reason I'd use it. I was like 15. But of everything I've ever made, this gets the most attention, and I'm not entirely sure why. It doesn't even pass all statistical tests. I'd probably use it over LCG though.

``` uint8_t x,a,b,c; uint8_t randRNG8() // Originally unsigned char randomize(). { x++; //x is incremented every round and is not affected by any other variable a = (a^c^x); //note the mix of addition and XOR b = (b+a); //And the use of very few instructions c = ((c+(b>>1))^a); //the right shift is to ensure that high-order bits from b can affect return( c); //low order bits of other variables } ```




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: