In my youth, I often looked to real games for inspiration. Card games were one such source and one I drew from often. Some attempts, like Stud, were simple high and low games. For March’s program, Hit tackles the more complex Blackjack, eschewing graphics to focus on gameplay.
No cards needed.
Forgoing direct realism, Hit does a decent job replicating a game of Blackjack. Since each card is single letter, 10 is represented by a T. Subtleties like splits are left out as well. One obvious change is Hit dispenses with the ace, using 1 instead. This eliminates needing to determine if the ace is 1 or 11. Removing the ace has the side effect of eliminating an instant 21 or Blackjack. The game’s name is apt, as Hit doesn’t play like Twenty-One or its variants.
With that said, Hit is still a fun game to play. You start with a $1000 and can bet up to $500 of it at a time. You can’t bet less than $10 unless you have less than that. Since the bank has $9,000, your goal is to win $10,000 and thus break the bank.
Once you’ve bet, the game shuffles the deck and spits out the cards. There are no suits, only numbers. Good lucking counting cards, everything is random—well, pseudorandom. Strategy is the same as before and may luck be on your side.
Digging into the deck.
Hit, on a whole, is a straight forward program. There isn’t much in the way of tricks or fancy code. It’s well laid out and readable, using subroutines and arrays as needed. You could tell this was a game from the later programming years. That doesn’t mean it couldn’t be optimized or improved.
From a design perspective, you’ll find the code focuses on what is being displayed. Although devoid of graphics, it still manages the text well. Using a well laid out display, Hit is careful to add enough spaces to overwrite longer lines. Things like your bet or the pot will properly display as they shrink. It is subtle, but effective approach.
Displaying the cards is done using a pair of simple, reusable routines on lines 300 and 350. Each routine represents the hand for the player and dealer, but is otherwise the same. Each routine calculates the value of the card, which is added to respective hand’s total. Afterwards, it increments the card count and adjusts the display for the next card.
Within the routine, I use
VAL to calculate the value of the card. This may be the one piece of code I could consider a trick.
VAL is designed to evaluate strings as numeric expressions, which includes expanding variables. At the start of the program, I set up variables for each of the suit cards assigned the value of 10. Later, the values in T, J, Q, and K are converted to their values and added to the hand’s totals. Perhaps not obvious, it works quite well.
The shuffle routine is the most interesting, if simplistic, of the game. Using a
FOR loop, it shifts the cards around in the deck. Since the deck has no suits, it a shortened set of 13 cards held in A$ and is reshuffled each hand. The interesting part is that I use A$ for both displaying and calculating the deck, as described above.
Rethinking a few things.
Although I like the game as is, there are a few things I could change. The obvious one is adding in the ace. The logic needed isn’t that complex, although it would mean refactoring a few things. Yet it would improve the game play. A minor change, but a worthy one.
Using a full deck would also have been a good idea. Knowing it is a short deck, one can deduce what card they are most likely to get next. Shuffling the deck helps, but a larger deck would be wise.
The other would be to work some graphics back into the game. Although not needed, I miss the skeuomorphism a card graphic represents. Although the simplicity of the game works, that doesn’t mean it couldn’t look better. In fact, I’d seen many other card games from that era that created some decent looking decks. Even the simplified cards from Stud would have been more interesting.
One other change I’d prefer would be to remove the use of
INPUT$. I never liked the way ZX81 took you out of the screen to gather information from the user. A more subtle interface, anchored in the screen, would look better. It would also fit the overall design philosophy of the game.
Setting these aside, Hit works as designed. It has a smart layout and effective approach. In many ways, the changes above would be a pretty face on an otherwise good game.