jb55's avatar
jb55 _@jb55.com 4 months ago
nerd sniped myself even further and made a rust crate for droptables no idea why, just some recreational programming before bed. its fast! gn nostr 😴 image
jb55's avatar jb55
I was randomly thinking about loot/drop table implementations in games and naturally started thinking of the fastest way to implement large drop tables. gpt5 pointed me to this fascinating algorithm that is barely mentioned online, but it can turn sample any discrete probability distribution in O(1) https://y7k4.github.io/2021/03/23/alias-method.html its a bit brain bending and it took a good 20 minutes of staring to understand how it works, but its pretty cool. #nerdsnipe
View quoted note →

Replies (8)

Default avatar
Stvu 4 months ago
What’s a drop table?? Or should I ask Grok
jb55's avatar
jb55 _@jb55.com 4 months ago
like this image if it takes 500 boss kills on average for something to drop, you can just specify that drop rate and then when you sample the table it will roll it for you in O(1). You can have values that don't add up to 1, it all gets normalized. You can even have it roll multiple tables. one would roll rarity, then you could have it roll all the legendary items if it hits the legendary loot table. you can keep rolling this way. very common thing in RPGs, so was fun making this library.
jb55's avatar
jb55 _@jb55.com 4 months ago
Weird line wrapping bugs that would happen randomly. Basically a wrapped line would break the terminal.