Another terminal Blackjack game (check out my convoluted god functions!)

Hello, wordl!

After almost a week of coding (well, half of it was spent fixing bugs in my code), I’ve finished the first project in the Computer Science course.

I’ve blogged about it over at

The repository is located at my GitHub repository.

The code is convoluted and too long. I’ve since realized I need to make my code more modular to make it more readable and to make it easier to test for bugfixing. I’ve been told that my code is comprised mostly of god functions, which is not ideal.

Other than that, I’m pretty proud of it, since it took me almost a week of working every day for a few hours. I’ve rewritten some functions several times.

The game features doubling down, surrendering, insuring and betting. Aces are correctly valued at 1 or 11 depending on your hand. The game will reward accordingly if you win normally or if you win with a blackjack. The dealer will decide when to stop drawing cards based on the value of the player’s hands. In other words, it’s practically a complete blackjack game.

The only thing I haven’t implemented is splitting. Maybe if I were to completely rewrite it with more classes and functions, implementing it would be easy. But as it is right now, it’d take me too much work to implement it in the code as it currently exists.

I would love to hear suggestions and tips, if anyone were to be so kind to grant me some!

With that said, and after this very rewarding experience, I’m off to continue the CS course.

I’ve rewritten the whole code from the ground up based on the lessons learned from this first foray. It’s much slicker now. It also looks better when played on the terminal. It’s coded to support infinite players and infinite hands per player. The link is here, if you want to check it out and compare the changes.

No more horrible, messy, ugly to look at God functions. The code is shorter, simpler, and does even more than the previous code: it now supports multiple hands per player, and you know what that means? Splitting! It’s not truly blackjack if you can’t split, right?

Now it’s a fully-fledged blackjack game. Doubling down, splitting, insuring, surrendering, betting and as many hands per player as you’d like!

I feel like I’ve improved immensely and learned tons from this project.