Cheating Card Game

— 3 minute read

When I was in middle school I wrote a card game that cheated. Specifically, it was a simple game of blackjack, and it didn't always cheat. And I had no way of knowing if it was, or was not, being honest with me.

How I ended up doing this requires a little bit of backstory. At the time, my best friend and I enjoyed playing a couple of casino-style games. We had fun with them, but we were always talking about them cheating. Honestly, we didn't really think they were cheating. But it seemed we would be doing well, and suddenly, in a few games, we'd be out of the pretend money used in the game.

That's just the reality of (even pretend) gambling, but saying the games cheated made us feel better. Just like adults, I guess.

I'm not sure when, or how, this became an urge to see if I could make a game that actually did cheat, but I set out to do it. I had written some basic games, and so I took a blackjack game I had and started modifying it. I ended up with a simple game that would, on occassion, totally rip you off.

It worked like this: When you loaded the game initially, it would pick a random number between 1 and 100. Then, at the beginning of each hand, it would pick another random number. If the numbers didn't match, it played by the rules. If they did match, it would cheat.

And it didn't just give itself a perfect hand every time. I got really into this, too. There were options for how it would cheat you. Iit might let you get up to a score of, say, 13, and then give you a 9 or 10 to make you go bust. Or it would let you get to 19, but then give itself 20. There were 3-4 variations, and it would just pick one at random and go with it.

I got a lot of use out of this game. One thing I never did, though, was program in any time of indication of whether or not it was cheating. That would have ruined it. I don't know why, but knowing that it might be cheating made it more fun. And, of course, if I just lost all the time, I could console myself by saying, with good reason, that it might by cheating.

I've told this story pretty often during interviews. And sometimes, when encouraging people to learn by writing something, anything, no matter how pointless, this story comes in handy. Writing a cheating card game is pretty pointless. Except, it's not, not really. I learned a ton. I had never written a program this complex, with random numbers and different options of what it might do, decided entirely free from my input. Then coding the cheating algorithms themselves was a fun and complex problem for me. And that's not even mentioning how to load the game data, etc.

Whatever wacky idea you have, go for it. Has it been done 10,000 times already? So what? Do you own version. Feel free to over-engineer the hell out of it. You'll learn a ton, and it'll be more fun than any tutorial you come across.