Day 17, 18: More Improvements, Doubling Down, and Starting to Split

May 8, 2017

by — Posted in Coding

TL;DR – More Blackjack development. 

Once I got my MVP to a good state, I had my class advisor take a look to see what kind of feedback I could get.  The main feedback was to simplify my code even more to reduce nesting while loops and make the code more legible. Totally made sense since I was even getting confused sometimes when reviewing my code as to which loop I was in. So I did that before moving onto new features…and then did more of that as I moved to new features and identified other ways to make it even easier to read and maintain. 

Man, do I have a lot of functions in my code. 

I implemented doubling down, which wasn’t too hard to deal with.  All I had to do was check if a hand followed the rules I set for doubling, and if so, add more money to the bet. 

I also changed my game board to show card pictures instead of just text strings.  Now it looks prettier and easier to read.  This didn’t take too long either once I figured out how I wanted the cards to be printed. 

Splitting, on the other hand, is a pain.  I figure I have two choices for how to implement splitting when it comes to tracking each individual hand:

  • Make a list of lists, where each list represents a hand 
  • Make a new entry in the player dictionary specifically for a split hand

I feel like I will easily run into trouble with the nested list approach, so for now I’m going to approach it as if I’m making a separate dictionary entry for a split hand. If I magically find that I have an easier way to deal with it as nested lists, then I can always rewrite my code to do that. 

As I was pseudocoding the split feature, I realized that once I split a hand, I then have to be able to do all of the other regular options with those two hands…so that’s when I started rewriting functions to take an optional parameter in case I have to make a change to a split hand.  

It’s a lot of reworking code, but I feel like I’m learning a lot in terms of how to approach development and making functions as flexible as possible to handle different scenarios.  And I’m still having fun, so that counts for something, right? =)

Leave a Reply

Your email address will not be published. Required fields are marked *