r/gaming • u/[deleted] • Jun 25 '12
I was playing solitaire last night, and the computer didnt deal out a 5 of hearts...
[deleted]
1.1k
u/SkunkMonkey Jun 25 '12
You've never picked up a real deck of cards to play solitaire only to realize that one of the cards was missing after you started playing?
Solitaire, taking card simulation to the next level!
→ More replies (37)
2.1k
31
u/mnighm Jun 25 '12 edited Jun 25 '12
As a programmer who wrote a solitaire program in college, I had the exact same thing happen randomly in a program I wrote. It was an issue in the shuffle algorithm. Basically I was taking the cards in the deck and randomly shoving them into a slot an array. If a card was already in that slot I would switch the cards and try and find a place for the existing card elsewhere. This is a stupid way to shuffle by the way, but that is what the professor wanted.
Unfortunately I was a smartass who thought he would make it easy on himself and define the array as one element larger than it needed to be. This was so that the first element of my array would be 1 not 0. However I did not have the bounds on the array set correctly. 0 could be used by the shuffle algorithm but not by anything else. There was a one in fifty-three chance that a card would end up in slot 0. My professor just so happened to have the bug pop up while he was testing my program.
EDIT: Forgot a word.
EDIT2: I was a dumb ass. There was a one in fifty-three chance that the bad slot would be empty. Had not thought about the math till today when bagelmanb called me out on it. I probably did not play the game all the way through to notice.
→ More replies (16)
1.1k
u/Lies_About_Expertise Jun 25 '12
Senior software developer here, and I can explain how it happened. What most likely happened was a developer got bored. I know when I get bored after coding for a while I add little things to the code. Just last week I was working on a soon to be released game, and added a line of code that gives the player a 1 in 10 million chance of randomly dying on any given turn (it's a turn based RPG). It's all great fun.
→ More replies (58)777
5
130
552
112
78
Jun 25 '12
Does anybody else note the lack of a cursor on the screen? Or the lack of a selected card? He just dragged it off screen to take the screen shot. Now he's doing his happy "I just tricked those Redditards and got to the front page" dance.
→ More replies (2)
89
u/NewBlueBlood Jun 25 '12 edited Jun 25 '12
counting flowers on the wall, that don't bother me at all, playing Solitaire til dawn, with a deck of 51... edit:I accidentally a lyric (or two)
→ More replies (12)
56
61
u/rnelsonee Jun 25 '12
Yup, it's a known bug. This is what happens when you don't have a dedicated test department, I suppose :)
18
8
u/makaveli151 Jun 25 '12
Also happened to me last week. Except they dealt me 2 Ace of Clubs. Figured I might as well post it as well.
14
6
u/BlackestNight21 Jun 25 '12
♫ playin solitaire til dawn, with a deck of fifty one... ♬
→ More replies (2)
6
2
u/uselesslyskilled Jun 25 '12
That's only 34 cards. There's way more than that, that's missing
→ More replies (4)
1.2k
u/ReanLu Jun 25 '12
Curious... I believe this image to be shopped!