15 ms·
Show HN: A Set of Dice That Follows the Gambler's Fallacy
- overcast 9y ago"A terrible idea is born." :D I can only imagine what will be made on top of this.
- nerdponx 9y agoThis "unfair RNG" issue was big in Dota 2 (a popular video game) for a while. They ultimately implemented something similar and AFAIK now all "random" effects use it.
- Blackthorn 9y agoYou mean the pseudorandom distribution? IIRC that was even a part of DotA 1.
- Quarrelsome 9y agoyeah but now it applies for I think everything. The last one to go was Spirit Breaker's bash. Prior to that PA's crit. Funny thing is that with PRNG you can "warm up" via farming creep camps so if you don't crit in say 5 attacks you can go look for a fight and be "guaranteed" a crit with your first swing.
- nerdponx 9y agoI actually wrote a blog post about this: https://www.gregwerbin.com/blog/2015-06-18/bernoulli-runs-simulator.html https://www.gregwerbin.com/blog/2015-06-18/bernoulli-runs-si...
- fiatjaf 9y agoI googled "RNG" because I wanted to know what it meant, but was presented with an interactive widget that generated numbers.
- sloppycee 9y agoRNG stands for Random Number Generator. It is used colloquially, in gaming, to refer to the probability of certain random events or the underlying implementation of them.
- avisser 9y agoIn its most personified form, the RNG transforms into RN Jesus to whom you pray for good video game luck.
- RugnirViking 9y agoIn the case you weren't joking: RNG stands for Random number generator. It is an abbreviation commonly used in video games.
- vacri 9y agoAlso in cryptography, in things like CSPRNG (cryptographically secure pseudo-RNG)
- reificator 9y agoThat's exactly what it is. RNG = Random Number Generator.
- deleted 9y ago[deleted]
- xzel 9y agoNot quite all; there are still a handful of skills that use a discrete or flat distribution but practically all attack based changes use the pseudo random distribution. For more info: http://dota2.gamepedia.com/Random_distribution http://dota2.gamepedia.com/Random_distribution
- Pfhreak 9y agoInteresting, and at first I was excited about the possibilities in something like D&D, where a series of bad rolls can have you feeling down. "I'm due for a critical hit any swing now..." Players would love that! Make my hero feel more heroic! The inevitable comeback! But then I thought about the inverse case -- you are doing really well, and now you are due for a failure. Or series of failures. That would feel awful. We have a lot of emotions around dice rolling. I wonder if players really want from their dice. Would players prefer dice that are secretly unevenly weighted towards good rolls? Would they still want those dice if they knew they were weighted?
- xori 9y agoI made this specifically for my online D&D sessions. I can tell you that nobody was suspicious when I replaced the standard Math.random() with this version, and all of the "I think your dice function is broken" statements all the sudden stopped happening.
- fenwick67 9y agoAs a D&D player I can see how this might be nice, but at the same time it would be frustrating to get a 20 for something stupid (passing a DC5 check) and know that it had a real effect on my chances for getting a 20 when I could actually use it (a critical attack roll).
- gerdesj 9y agoThere are times in a RPG for (a GM/DM) relying on dice for something and when not to. For some people driving appears to be like bumper cars but for most of us it isn't 8) Apply that to D&D and the player's approach to things should be used to bias or even dispense with dice.
- fiatjaf 9y agoBetter have games without dice rolls. Unexpected events could come from other non-random sources (like the combination of a lot of factors involving other players actions).
- ideonexus 9y agoA great application for this is in randomizing playlists. My friends, who are also CS grads and should know better, have often complained that their MP3 players, CD carousels, etc play the same music too often claiming that the random is broken, when a song repeating in a short period of time or other songs never playing is what you would expect from a truly random selection. Using this algorithm, you'd be sure to hear all of your songs. I'm guessing most music services already do something like this.
- nxc18 9y agoI think the original Zune had a bad randomizer. In my experience it would tend to play two songs from the same artist back to back. Whether this was because they had a botched 'smart' randomizer or because they in fact used true random to shuffle, I may never know.
- abritinthebay 9y agoThe iPod and iTunes used to do this too - it’s because of a behavior you’d actually expect in a true randomizer called clustering. Supposedly Jobs specifically “fixed” this behavior and it’s why there used to be (still is?) a slider that allowed you to customize that behavior.
- drewrv 9y agoThis is also an example of users saying they want one thing (randomness) when really they want something else (variety).
- _Marak_ 9y agoI'm probably very wrong, but I still feel there is some undiscovered science when it comes to RNG and the fallacy of the maturity of chances ( Gambler's Fallacy ). Einstein believed the universe was deterministic. Just because it appears to us that there is no correlation between independent events ( the roll of a dice ), does not mean that there isn't some underlaying variable that we are unable to measure or perceive which is affecting the outcome of the roles.
- abritinthebay 9y agoThere almost certainly is but you can’t collect the data. At some point quantum effects will come into play too. Theoretically all physical processes are predictable, but in practice there is a limit.
- boyce 9y agoHad the pleasure of meeting Alain Aspect once who would definitely have, at that time at least, argued the opposite.
- abritinthebay 9y agoWell he’d be coming at it from the quantum angle, which I agree makes it more complex. However I did add that as a major caveat.
- robotresearcher 9y ago> Theoretically all physical processes are predictable If you count a radioactive decay event as a physical process, then this is not so.
- abritinthebay 9y agoI don’t. Radioactive decay is practically the very definition of the quantum effects I mentioned.
- careersuicide 9y agoJust wanna say: I love this.
- kator 9y agoI often use google "flip a coin"[1] for stupid things and the other day I was wondering why almost every single time it came up heads. I started to wonder if there was a browser rng problem or the code was crazy etc. [1] https://www.google.com/search?q=google+flip+a+coin https://www.google.com/search?q=google+flip+a+coin
- yathern 9y agoJust tried it, and my first four flips were heads - you may be on to something... I'll keep flipping and come back with my results. Update: Heads stayed ahead by a few for quite a while, until they tied at 45 each. It's a race to 50, my money is on tails - it's due for a comeback! Update: Tails takes the lead, 46-47! Update: 47-49 Tails is in position to strike! Update: Tails wins! 48-50! (two more clicks to make a sum of 100 results in a perfect 50/50 split) It's surprisingly fun to anthropomorphize heads vs tails, and commentating on their battle
- wpietri 9y agoObligatory relevant XKCD: https://xkcd.com/904/ https://xkcd.com/904/
- wpietri 9y agoAnd for those who are really in to this topic, Taleb's "Fooled by Randomness" is great. There's a section on how financial traders often end up ranked like this. Somebody makes an effectively random bet, but it pays off big so they're treated as a genius. It made me see all sorts of organizations differently.
- ianamartin 9y agoTaleb is the Deepak Chopra of Economics and Probability. What he says sounds really important, but is mostly a bunch of horseshit.
- 9y ago
- bigato 9y agoNow I really want physical loaded dice which follow the gambler's fallacy! Is it too crazy of an idea?
- pmiller2 9y agoI was a little disappointed when I clicked, too. I can't think of a way you could make physical dice like that, unless maybe the faces were LEDs? That might be too fragile.
- Mister_Snuggles 9y agoApple has a patent[0] for a fall-protection system that will rotate the phone while it's in the air. If something like that could be made small enough to fit into a die, that would work. The biggest challenge will probably be the power supply. I'm sure that a processor, accelerometer, and the Taptic Engine (the thing that provides vibration and haptic feedback in Apple devices) are all small enough to fit in a typical die. Of course, something like this could easily be built into a larger novelty die. Bonus points should be awarded if the die is perfectly balanced when it's not actively adjusting itself in mid-air. [0] http://appleinsider.com/articles/14/12/02/apple-patents-active-fall-protection-system-that-shifts-iphones-in-midair http://appleinsider.com/articles/14/12/02/apple-patents-acti...
- xori 9y agoOh my god, you totally could use reaction wheels. https://www.youtube.com/watch?v=n_6p-1J551Y https://www.youtube.com/watch?v=n_6p-1J551Y
- Mister_Snuggles 9y agoWow - that is cool!
- michaelbuckbee 9y agoThat's really clever - I've been wondering how small and quiet you could make such a device. Can you imagine how cool it would be to have one of those attached to a VR controller? You'd be able to get real (albeit slight) resistance when you interacted with things.
- hesdeadjim 9y agoThis reminds me of Sid Meier's talk at GDC about having to game the random number system because of player's expectations: http://www.gdcvault.com/play/1012186/The-Psychology-of-Game-Design http://www.gdcvault.com/play/1012186/The-Psychology-of-Game-... More often than not, true RNG in game design takes a back seat to fun.
- eterm 9y agoPlayerunknown's battlegrounds currently suffers from item spawns being "too random". You can go houses without finding a rifle then suddenly find 2-3 practically on top of each other. They could do with learning a little from other games and making it a little less random. Ultimately you can see it as a bug in human reasoning but we're the ones playing the game.
- fenwick67 9y agoTBH I like the current uniformity of the item spawns. It varies the gameplay and forces you to adapt. If every house had one pistol and one rifle it would get pretty dull. Raiding 3 houses and only getting a crossbow, bandages, and SMG magazines is frustrating but it's exciting. Just last night I got to #3 or #4 with a crossbow and a pistol.
- lawtguy 9y agoThe MMO City of Heroes did something similar to this. They called it the streak breaker: http://cityofheroes.wikia.com/wiki/Attack_Mechanics#The_Streak_Breaker http://cityofheroes.wikia.com/wiki/Attack_Mechanics#The_Stre... Basically, the higher your chance to hit with an attack was, the the sooner it would break a streak of misses and force a hit. This is definitely not random, but seems to be more satisfying to the player. Plus it no doubt cuts down on the number of complaints on the forums about "unfair" RNG.
- cableshaft 9y agoThere was an old flash video game I worked on a long time ago where I did exactly this. I had a boss with two main attacks, and I didn't want it to be super predictable A/B/A/B, so I had it pick between A and B randomly, then reweight the probabilities, so if it picked A, instead of 50% A, 50% B it'd now be 25% A, 75% B. If it picked A again it'd be down to like 12.5% A, 87.5% B. If B then got chosen, it'd flip flop to 75% A, 25% B, etc. The result was it mostly went back and forth between the two, but would do some attacks 2 or 3 times in a row before switching back to the other. You can actually play it right here and go direct to the Boss Fight if you wanted to: http://briancable.com/clock-legends/ http://briancable.com/clock-legends/
- hn_throwaway_99 9y agoHmm, but by the algorithm you describe you are MORE likely to get a "super predictable" a/b/a/b than you would with just an independently random coin flip each time. That is, strings of multiple As or Bs in a row is less likely with your algorithm, but you make it sound like that's what you wanted.
- cableshaft 9y agoNo, you misunderstand. I didn't want it to be always A,B,A,B, but I also didn't want it to be an even coin flip and risk an A,A,A,A,A,A,A or whatever (like in the play Rosencrantz and Guildenstern are Dead). With my method, it was possible for the same move to be picked 2 or 3 times in a row, but it mostly went back and forth, so the player was definitely going to encounter both moves, but they couldn't know for absolute certain which move the next one would be (and they both needed you to kind of quickly get into different positions before getting hit). The type of pattern you'd usually get with mine was more like A,B,B,A,A,B,A,B,A,A,A,B,B,A.
- andy_wrote 9y agoThere's a probability model called the Pólya urn where you imagine an urns containing numbered balls (colored balls in a typical example, but to draw the comparison with dice we can say they're numbered 1-6), and every time you draw a ball of a certain color, you put back more balls according to some rule. A few probability distributions can be expressed in terms of a Pólya urn, see https://en.wikipedia.org/wiki/P%C3%B3lya_urn_model https://en.wikipedia.org/wiki/P%C3%B3lya_urn_model. A fair 6-sided die would be an equal number of balls numbered 1-6 and a rule that you simply return the ball you drew. You can get a gambler's fallacy distribution by, say, adding one of every ball that you didn't draw. I read the code as a Pólya urn starting with 1 ball 1-N and doing that on each draw plus reducing the number of balls of the drawn number to 1. Also related, in 2d space, is the idea of randomly covering the plane in points but getting a spread-out distribution, since uniformity will result in clusters. (If you're moving a small window in any direction and you haven't seen a point in a while, you're "due" to see another one, and vice versa if you just saw a point.) Mike Bostock did a very nice visualization of that here: https://bost.ocks.org/mike/algorithms/ https://bost.ocks.org/mike/algorithms/
- xori 9y agoThank you! Sometimes the hardest thing is knowing what to google!
- duxup 9y agoI do a lot of furious googling thinking: "Oh man this has to be a thing but what could it be and how would someone describe it?... awe forget it." Then months later by accident while looking at a completely different topic: "OMG there it is, the thing!"
- CPLX 9y agoIndeed. This happened to me the other day trying to find the name for a domino joiner while googling for biscuit joiners.
- vinchuco 9y ago
- andrepd 9y agoEh, I thought this was something more mathematical, like non-transitive dice (https://en.wikipedia.org/wiki/Nontransitive_dice https://en.wikipedia.org/wiki/Nontransitive_dice). Apparently it's... a weighted random number generator? in node.js?
- xori 9y agoYep it's nothing fancy. But I've yet to have seen it done before.
- exabrial 9y agoA good application for this would be prevent "Starvation" when doing random rewards in a video game. For instance, if a special item is to be dropped after defeating a boss...
- deleted 9y ago[deleted]
- root_axis 9y agoThis reminds me of an article discussing the perceived outcome of RNG decisions in video games. In many types of games, the system will display a percentage chance of success for a given action which allows the player to make risk assessments regarding possible choices. Unfortunately, the unmodified RNG behavior creates an unpleasant experience for the user because the unweighted random outcomes feel "unfair" when failure streaks pop-up, thus, game designers almost always introduce some type of magic cushioning to the RNG so that the user never faces too many repeated failures.
- NelsonMinar 9y agoFolks who play Blizzard games call this the "Pity Timer". World of Warcraft, Hearthstone, and Overwatch all have some mechanic where your odds of getting a desireable thing go up if you've had more recent disappointments. RNJesus is merciful.
- heartles 9y agoIt's also known as a mercy pull in kingdom hearts Union X, where after a few failed attempts of trying to get a high level medal they will guarantee you one on the next pull.
- nickm12 9y agoI had the privilege of studying probability from G-C. Rota. One of my favorite quotes from him was "Randomness is not what we expect", which he used to describe the phenomenon of people disbelieving that random data was actually random. Another great was "This will become intuitive to you, once you adjust your intuition to the facts."
- DINKDINK 9y agoA good way to show how the "Randomness is not what we expect" phenomenon manifests is the following. Given a fair coin that outputs Heads (H) or Tails (T), which of the following sequences is more or less probable HHTHTT or HHHHHH Answer: Both are equally probable strings to be generated by the fair coin and each should occur once in every 64 sequences (~1.56%)
- andy_boot 9y agoTrue But I would like to show you an interesting counterexample which requires changing the rules slightly. If we toss a coin and keep tossing until one of the below sequences turn up then which sequence is more likely? HHHHHH THHHHH Answer: THHHHH. Only 1/(2^6) of the time it will be HHHHHH. The only way to get HHHHHH will be if the first 6 flips are heads. If you don't flip a head you must have got a tail which means THHHHH will always appear before HHHHHH.
- ianamartin 9y agoI think the real issue that most people have understanding this stuff is that they don't have a clear grasp of dependent vs independent events. We tend to use the fair coin or the fair die as a common way of talking about things, but I've found that this is problematic for a lot of people. First off is the use of the word fair. People not from a background in statistics don't think of that word the way we do. They think of it as an attribute of the object itself. The the coin or die is 'fair' in the ethical sense of the word. Second is the experiential understanding: 'This coin is fair and therefore should flip heads and tails with equal frequency. It's the same damn coin, and I flipped it a thousand times! Why are these crazy stats people telling me it comes up heads and tail equally often? It doesn't, dammit!' What I've had some success with helping people understand independent trials is to get them to envision flipping 6 different coins at the same time. Then you can sort of walk them back into understanding that flipping 6 different coins once is no different from flipping the same one 6 times. The events are totally unrelated, and a past event is not a predictor of the future. Plus, you can actually map out the math for them on the spot. .5 * .5 * .5, etc. That's just my experience trying to explain things though. Would love some criticisms if there are better ways to go about this.
- dmartinez 9y agoI like to think of this as "human random". It's easier to get along with people using this type of algorithm.
- sebnap 9y agoI think they didn't trust your programming skills as much as the possibility of absurd sequences :D
- xori 9y agoUnfortunately I think you're right.
- closed 9y agoAt first I was confused, because statistical models that aren't temporally independent are very common. But it's very clear from the comments that having dice that aren't independent between rolls is incredibly in demand :o, and having the right words to google can be tricky. (I feel like there's an important lesson there)
- xori 9y agoThis is what I found my University degree was best for. Teaching me what the name is, of the thing to Google in the future.
- deleted 9y ago[deleted]
- colanderman 9y agoA simpler (albeit quite deterministic) way of accomplishing this is to use an LFSR [1] or the CRC [2] of an incrementing counter. Such a sequence of values "looks random" under many measures but also has the probability that you will eventually get an even distribution of values (after the period of the counter). [1] https://en.wikipedia.org/wiki/Linear-feedback_shift_register https://en.wikipedia.org/wiki/Linear-feedback_shift_register [2] https://en.wikipedia.org/wiki/Cyclic_redundancy_check https://en.wikipedia.org/wiki/Cyclic_redundancy_check
- IncRnd 9y agoBingo cards (the real ones, not the theoretical ones) often have human interaction as one of the steps in their creation. This is so they appear random, distinct, without patterns, etc.
- Tade0 9y agoKudos for the "I don't get it" section.
- erikb 9y agoAnd then there's also the gamblers wisdom: If the dice was facing a 6 for too many times in a row, look for another game.
- jonjonjonjon22 9y agoI'm not a programmer but I've thought about this a lot. It'd be interesting to know if my simple solution here has something wrong with it. My idea is based on time - if we assign each song to a 1/1000th of a second, we play the song that matches the 1000th of a second when the next song is called. In this case, I'm referring to the 1/1000th of a second of current time of day. Depending on the song´s position in the second that I change tracks, is what song gets played. A bit more randomness (if this is needed) could come if we use Pi - for example, we can run through a series in Pi which adds to the ID of the song. Differing track lengths then do the job of ensuring that we always wind up on a different song in the loop. The above seems to my layman's eye to be a simpler solution, at least.
- doodpants 9y ago> I made a chatbot that rolled dice, and it was constantly criticized for being "broken" because four 3's would come up in a row. > These accusations would come up even though they (all being computer science majors) know it's possible (although unlikely) for these events to happen. They just don't trust the black box. I am reminded of the approach that GamesByEmail.com used to address this criticism: http://www.gamesbyemail.com/News/DiceOMatic http://www.gamesbyemail.com/News/DiceOMatic
- cdelsolar 9y agowhy was that a download?
- nfriedly 9y ago> As I promised earlier, if you donate to the site and are unhappy about the rolls, let me know and I will pull a die out of the machine, melt it flat and mail it to you, as an object lesson to the other dice. Tangible revenge. Hah! That might be the best donation "gift" I've ever heard of!
- Sawamara 9y agoThis is actually useful for many rpg games.
- Impractical 9y agoNow we need one that follows the inverse gambler's fallacy. Ever since I taught my wife about the gambler's fallacy, it seems like she falls into the inverse of it. It's pretty amusing actually.
- dcookie 9y agoThis reminds me of the first scene in Rosencrantz & Guildenstern Are Dead. https://www.youtube.com/watch?v=RjOqaD5tWB0 https://www.youtube.com/watch?v=RjOqaD5tWB0
- YCode 9y agoI wonder if this could be / has been applied to loot tables in video games in order to keep the player interested in playing. I've designed a few loot tables and the Gambler's Fallacy is a criticism I often have to deal with when people don't understand why a given item hasn't dropped despite them having killed a mob enough times to statistically warrant it.
- woodrowbarlow 9y agoon the other side of the coin, monster hunter players claim that the game actively avoids giving them items that they want in order to increase the (eventual) satisfaction. they call it the "desire sensor". http://monsterhunter.wikia.com/wiki/Monster_Hunter_Wiki:Monster_Hunter_Vocabulary#Desire_Sensor http://monsterhunter.wikia.com/wiki/Monster_Hunter_Wiki:Mons... the studio has denied the existence of any such mechanism.
- ProgrammerMatt 9y agoCan someone explain to me why there is such a large discrepancy for the different sides for math.random()? seems fairly large
- xori 9y agoIt's actually not that bad. The graph just emphasises the subtle differences. The worst one (a 10) was rolled 696 times extra over the expected number of 100,000 rolls. That's like 0.3% deviation.
- marcofiset 9y agoLooking at the Y axis scale shows that the variation is not as much as it seems.
- Thespian2 9y agoFor board games, like "Settlers of Catan" where resources are generated based on rolls of 2d6, one could use an analog version of this with a cup containing 36 chits, of the numbers 2-12 according to the normal distribution, _without_ replacement. You would still get the randomness of ordering, but over 36 draws/turns would get a complete "average" distribution. If that is a bug or a feature is left as an exercise for the reader.
- cletusw 9y agohttps://boardgamegeek.com/boardgame/20038/catan-event-cards https://boardgamegeek.com/boardgame/20038/catan-event-cards
- dllthomas 9y agoSure, the Gambler's Fallacy has worked out poorly in the past... but doesn't that mean it's due?
- eriknstr 9y ago> I made a chatbot that rolled dice, and it was constantly criticized for being "broken" because four 3's would come up in a row. > These accusations would come up even though they (all being computer science majors) know it's possible (although unlikely) for these events to happen. They just don't trust the black box. This reminds me of a talk [1] given at Game Developer's Conference (GDC) about the game Civilization, in which the Sid Meyer -- creator of said game -- spent a bit of the time talking about the difference between fairness and perceived fairness. The talk is only an hour long and worth watching. [1]: https://www.youtube.com/watch?v=AJ-auWfJTts https://www.youtube.com/watch?v=AJ-auWfJTts
- vacri 9y agoWhen your battleship is destroyed by a peasant with a pitchfork, there's not a lot of perceived fairness...
- mighty_bander 9y agoPshaw. Make real dice that do that and I'll get excited.
- deleted 9y ago[deleted]
- vanderZwan 9y agoA similar, simpler idea is sometimes used in games: you put all choices in a "bag", then draw from the bag until it's empty, then put everything back. Tetris is the go-to example. Tetris has seven tetronimos, and in most modern implementations you're guaranteed to see them in sets of seven in random order. http://tetris.wikia.com/wiki/Random_Generator http://tetris.wikia.com/wiki/Random_Generator This is pretty essential to make competitive play err on the side of skill rather than randomness: pro-players can anticipate and plan for this. For fun, here's a recent Tetris head-to-head speed-run from Awesome Games Done Quick, with pretty good narration about the tactics involved: https://www.youtube.com/watch?v=PeNB4w99FiY&t=1h21m15s https://www.youtube.com/watch?v=PeNB4w99FiY&t=1h21m15s
- methodin 9y agoIt's always nagged me that statistical problems are scoped so small. Surely in saying there's 6 outcomes on a dice you'd obfuscated the billions of interactions between atoms and input possibilities in doing so. Thrower A and thrower B will undoubtedly throw slightly different which might actually constraint the outcomes and skew the 1 in 6 percentages? It's similar to me to condensing 30 characters to 5 via an algorithm. You can go one direction but not the other and if your model was centered around the resulting 5 it doesn't really reflect what's actually happening which may skew the probabilities quite a bit. e.g. if the algorithm was "if first letter is not q, then first letter in output is q". If you were saying each has an equal percentage of occurring it'd be flat out wrong. * I am not a statistician and have no idea what I'm talking about
- ianamartin 9y agoFor these kinds of exercises about fair dice and fair coins, it's a lot like the kind of jiggery-pokery that happens in Physics classes and stuff. "Under ideal circumstances . . .", "In a perfect vacuum . . .", etc. Outside of games, for which this was explicitly created, these kinds of things are learning tools to understand distributions and dependent vs. independent events, and it also makes a separate point about assumptions. In reality, if we were wanting to predict the outcome from a real dice-throwing event, we would either sample the results from actual people throwing dice, or we would simulate the results based on parameter inputs for exactly the types of things you are talking about. Of course, no one really cares that much about dice, other than people who play board games with dice. :) So substitute any other stochastic method for generating an outcome that does matter, and the statistical approach will generally be the same: either sample or simulate. Obviously there are exceptions, but that's really the basic idea.
- biesnecker 9y agoIn 2010 I asked a similar question on StackOverflow for choosing the option that would have the correct answer in multiple choice tests: https://stackoverflow.com/questions/3099153/better-random-feeling-integer-generator-for-short-sequences https://stackoverflow.com/questions/3099153/better-random-fe...
- mwexler 9y agoFinally, Spotify's shuffle algorithm can be fixed! Thank goodness you created this.
- snake_plissken 9y agoRandom question I've always had issues resolving: if the Gambler's Fallacy is real, how can you detect loaded dice?
- zem 9y agoreminds me of a very interesting demonstration from martin gardner. draw a 6x6 grid, and write a random digit in each cell, proceeding row by row. now count the number of pairs of consecutive (x, x) going horizontally versus vertically; you will almost always get doubled numbers in the columns because that's how random numbers work, but almost never in the rows, because when people are trying to generate "random" numbers by hand they avoid runs or other patterns.
- gpawl 9y agoThe NBA Draft Lottery is similar in spirit: https://en.wikipedia.org/wiki/NBA_draft_lottery https://en.wikipedia.org/wiki/NBA_draft_lottery
- deleted 9y ago[deleted]
- onetwotree 9y agoVideo games, especially competitive ones, do this to limit the effect of randomness on the outcome of the game, while still keeping the sequence of random events unpredictable enough to "feel" random and preventing simple exploits. DoTA2 uses a simple distribution based on the number of "rolls" since the last successful one - P(N) = P0 * N, where P0 is the base probability and N is the number of rolls since the last successful one[1]. It keeps both "hot" and "cold" streaks from being too much of an issue, although that doesn't stop players from cursing the RNG gods when they lose. [1] http://dota2.gamepedia.com/Random_distribution http://dota2.gamepedia.com/Random_distribution
- vacri 9y agoOn a related note, a colleague once worked at a place where they did this for on-call: Everyone has an on-call score. Every week, the person on-call had their score set to zero, and everyone else incremented by one. You could plan out the next couple of months this way, and it provided an elegant way for new hires to take their place - they start at zero, and were generally familiar enough by the time their number came around. There were some housekeeping rules to work around the organicness of human life - if someone went on holiday they kept their score, for example - but overall it seemed to work.
- smallnamespace 9y agoThis shows up a lot (predictably) in actual games, e.g. Hearthstone sells you digital cards, and the randomization specifically guarantees that the time between rare cards is capped [1]. Having unusually bad luck (e.g. opening 100 packs and not getting a single legendary card, when the average would be every ~20 packs) feels bad and probably loses Blizzard a customer, so the solution is to cut off the downside tail of the distribution. [1] https://www.reddit.com/r/hearthstone/comments/3z7jyh/pity_timer_on_packs_opening_and_the_best_strategy/ https://www.reddit.com/r/hearthstone/comments/3z7jyh/pity_ti...
- 18nleung 9y agoHow exactly does the roll() method work? Can't seem to parse the meaning of `runningSum` and `mark`. roll() { const sum = this.state.reduce((p, c) => p + c, 0) const r = Math.random() * sum let runningSum = 0 let result = -1 for (let i = 0; i < this.state.length; i++) { const mark = this.state[i] runningSum += mark if(r < runningSum && result === -1) { result = i this.state[i] = 1 } else { this.state[i]++ } } // Add 1, so the die roll is between 1 -> size of die return (result + 1) }
- 18nleung 9y agoOk — I think I've figured it out, but let me know if I've gotten anything wrong: At the outset, `this.state` is initialized as an array of `1`s — [1, 1, 1, ... , 1] — the number of `1`s is based on the `size` parameter passed to the `Die` constructor. So for a 4-sided die, `this.state` would initially be `[1, 1, 1, 1]`. `sum` is the accumulated sum of `this.state`, but it helped me to think of the `sum` variable as a number line. Continuing with the 4-sided die case, we'd have a number line of length 4 at initialization (sum of `[1, 1, 1, 1]`). In the context of a number line, though, `this.state` can be thought of as giving the geometric positions of each possible result. `this.state[i]` simply gives the length of the valid region for a certain result. At initialization, each result of `1` to `4` of our four-sided die would have a length of 1 on the number line (again, `[1, 1, 1, 1]`). In concrete terms, the region [0, 1) on the number line would yield a roll of `1`, the region [1, 2) would yield a roll of `2`, ... , the region [3, 4) would yield a roll of `4`. With that in mind, we can think of `r` as choosing a random point on the number line between 0 and the end of the number line. At initialization, it simply chooses a point on [0, 4), since 4 is the length of our number line. `runningSum` is our location on the number line. The code chooses a result here using the boolean expression `(r < runningSum)`, but it helped me to think of it in flipped terms: checking if `runningSum` is greater than or equal to `r`. In essence, we're traversing the number line starting from 0. Back to our four-sided die example: let's say `r`, the random point on the number line we got, was 2.5. At initialization we'd start by checking the region of the number line where `1` would be our result. Since `this.state[0]` (the length of the valid region for the result `1`) is 1, we can say that if we choose a point randomly on the number line [0, 4) and it is on the interval [0, 1), our roll is a 1. However, 2.5 is not on [0, 1), so we add the length of the region where `1` is valid to `runningSum` (our location on the number line) so we can move on to the next region - the interval where `2` is our result. The length of this interval is stored in `this.state[1]`, and is also equal to 1 (`this.state` = `[1, 1, 1, 1]`). In terms of our number line, the valid interval is thus [1, 2). At this point, our location of the number line, `runningSum`, is 2: still less than 2.5. Next, we'd get to the region for the result `3`, `this.state[2]`, and we'd be at [2, 3) on our number line. At this point, our `runningSum` (location on the number line) is 3, which is greater than `r` (the randomly chosen point on the number line), 2.5, and we have our result. (sidenote: the variable `result` being equal to `-1` is a sentinel value and prevents `4` also being considered a valid roll by virtue of it being greater than 2.5 as well. After this iteration, `result` is set to `2` - changed to `3` in the return statement). The "magic" of the die comes in when traversing the number line over the non-valid regions, however. While we're traversing the number line, we're also resizing the valid regions for each result and extending the line for the next roll. If we go back to the example in the previous paragraphs with the 4-sided die, we saw that since `r` (our randomly chosen point on the number line), 2.5, was not on [0, 1), the result of our roll was not `1`. To increase the likelihood of `1` in the next roll, we increase the length of the number line and the region where `1` is our roll: `this.state` becomes `[2, 1, 1, 1]`, the valid region for a roll of `1` becomes [0, 2), and the size of the number line grows to 5 (however, this expansion of the number line does not apply to the current roll). At the culmination of our first example above, `this.state` would be `[2, 2, 1, 2]` — we'd increase the size of the valid region for each result except for `3`, our result from the previous roll. For the next roll, we'd choose a random point on the number line between 0 and (2 + 2 + 2 + 1 = 7). In terms of probabilities, another `3` would be half as likely as a `1`, `2`, or `4`, independently.
- rivo 9y agoThe quote at the end is meant as a joke but it's interesting how often this is true. A lot of magic tricks rely on being prepared for different outcomes, while often trying for the least likely one first. This unlikely outcome happens surprisingly often and therefore makes the effect even more unbelievably amazing. I had a friend think of a playing card and any number (1-52). She picked the 6 of spades and the number 15 which is exactly the position where the card was located. It was only the third time I had done this trick with anybody. Obviously, card and number picking is not uniformly random, especially when you influence their choice (e.g. "pick a large number"). But the odds of someone guessing the exact combination should still be extremely low. A lot of what you see from David Blaine on TV is exactly this. He always has a backup plan but more often than not he doesn't need it.
- biafra 9y agoHow do I run this code? I thikn I succesfully installed the package with npm. There were some warnings but no error. But how do I run: > const RiggedDie = require('gamblers-dice') > const die = new RiggedDie(20) // for a d20 > console.log(die.roll()) // 1 -> 20 > console.log(die.roll()) // keep using the same instance Do I put it in a file? Do I copy paste it into a REPL? If so what provides that REPL? I am always surprised when sample code providers assume I know their languages ecosystem. UPDATE: Apparently I can use "node" as a REPL for this.
- mysterydip 9y agoThis will be great for game developers as many a player has complained that the RNG wasn't "fair" because they got so many fails in a row or never saw a critical hit or whatever, even though it was mathematically correctly random. Thanks, looking forward to using it!
- emodendroket 9y agoThis actually seems like it would be pretty good for applications like games or playing random songs.