10
3
Implement a program or function which simulates common dice for role playing games. It should handle at least the d6 and d20, the two most common dice.
However, it should work as stereotypical gamers expect them to work, and not as real dice work.
It is an in-joke between gamers, that one can have a specially lucky die for a very very important roll, by previously throwing a lot of dice, selecting those which resulted in a "1", then throwing them again, until you get a few which rolled a "1" multiple times. You then carefully preserve them, because they rolled a 1 multiple times in sequence, so the probability to roll a 1 next time should be extremely low.
Of course, this is not how dice work in real life, because the rolls are statistically independent.
Your simulated dice have to take previous rolls into account, and work similarly to how the gambler in the gambler's fallacy expects it to work. For example, if a lot of low numbers were rolled, the probability of rolling a higher number should be increased.
However, as this is cheating, you have to hide it well. This means, a casual glance upon the program should not reveal that you cheated. This means, explicitly saving the previous results and reading them on every throw would be too suspicious. You have to hide this "property" of your dice, and bonus points if you make it plausible deniable and disguise it as an honest mistake. (for example, you make your own RNG with an "unintentional" flaw)
Voters, please take into account how well hidden this "flaw" is.
The programs should be clear, and not obfuscated. It's too easy to hide evil code in an obfuscated program.
Related: http://thedailywtf.com/articles/introducing-the-lucky-deuce
– Neil – 2016-01-16T16:45:23.7134I'm voting to close this question as off-topic because underhanded challenges are off-topic now, and somehow this one slipped under the radar. – Mego – 2017-12-04T05:46:49.827
3How well hidden are we talking about? IMO, anything beyond the language's equivalent of
getRandomBetween(1,d)
would cause me to look deeper into it. – Geobits – 2014-03-08T20:54:12.793@Geobits : you can find a very nice example for how to solve underhanded problems here: http://codegolf.stackexchange.com/questions/19569/underhanded-code-contest-not-so-quick-sort?rq=1 I mean you can do anything if you justify it well enough, of course, the justification can be a big lie.
– vsz – 2014-03-08T20:57:50.300Godmaydamnit, java doesnt has enough quirks for underhanded stuff... – masterX244 – 2014-03-08T21:03:53.217