As suggested by @BH, I have turned Snap!Jack into a Card Engine by @loucheman game!
Here it is:
https://snap.berkeley.edu/project?username=johnce&projectname=Snap!Jack%20Redux
Feel free to leave critique or suggestions, all is welcomed!
As suggested by @BH, I have turned Snap!Jack into a Card Engine by @loucheman game!
Here it is:
https://snap.berkeley.edu/project?username=johnce&projectname=Snap!Jack%20Redux
Feel free to leave critique or suggestions, all is welcomed!
Hi Johnce, thanks for using my engine!
A few suggestions:
We should find a way to slow down the card dealing a bit!
Normally, in blackjack, bets are placed after all players and the dealer have received two cards. (The player receives two face-up cards, the dealer one face-down and one face-up card.)
Nice graphics!
I think I hear the shuffling sound before I actually see cards in motion.
You should collect the cards from the table before shuffling!
For me it seems that you never collect the cards from the table; for example in this picture
7♣️visible at the right edge of my hand is left over from an earlier round in which I drew twice. (Note that the other three cards you can see add up to 18, as the labelling says.)
The picture also shows the error message that I got when I said “n” to “do you want to play again?”
P.S. Oh, wait, how does the dealer’s hand add up to 26? Is the 10 that sticks out too far on the right also left over from an earlier deal, in which case the value of the dealer’s hand is 5+11=16, or is it really in the dealer’s hand, in which case the value is 5+1+10=16, because the dealer doesn’t have to count the ace as 11.
You do. Its meant to represent the shuffle happening off screen, as I do not know how one would go about animating such a thing.
I’m not sure what you mean by that, sorry…
This is actual a neat glitch. So the “empty” block:
![]()
empties a hand/deck/etc., but it can only do that if the list that is being used has something in it. This means that if you manually set the list to be empty without the “empty” block, the visual aspect will still remain.
It effectively does nothing if the list has already been emptied manual, which I found interesting. Especially when the “n” option has the same code, yet still deleted the most of the time.
All I had to do was remove the manual empty, which is getting rid of these:
![]()
I think this was from some leftover code when copied over bits of the original Snap!Jack to this version. I simply changed it to be “playerHand” and that seems to have fixed it.
Okay, I believe I fixed this? Basically, the way I made the valuing logic, it would have everything in the order it was added and evaluate from there. However, this is bad because you want aces to be looked at LAST, that way it can properly decide whether to make aces 11 or 1. My fix was simply adding:
![]()
that way aces will be at the back so everything else could added beforehand. This works since Card Engine has aces be dignified as “1”:
(See a1)
Oh, please, Johnce’s my father! Call me Joy! ![]()
Donezo!
Really? I’ve never personally played blackjack betting after dealing… Though, I will add the “hole” card (dealer one face-down and one face-up card), as I honestly forgot about that.
You do. Its meant to represent the shuffle happening off screen, as I do not know how one would go about animating such a thing.
Then what’s this:
bh: You should collect the cards from the table before shuffling!
I’m not sure what you mean by that, sorry…
When you’re playing an actual game, the dealer collects the cards from the previous hand off the table and sticks them at the bottom of the deck, then may optionally shuffle. (They generally don’t, which is why card-counting strategies work.) In your game, the previous hand stays on the table until the moment you’re ready to deal the next round. (Or maybe even later, because of the bug about not erasing cards, but never mind that right now.)
Oh, please, Johnce’s my father! Call me Joy!
How come you don’t have your own Snap! account?
Sorry about bet time ! You’re right !
Hi Joy, great progress!
The block “empty” destroy the cards. Instead, after a round, you can trasfert old players and dealer cards to a discard pile.
When you’re playing an actual game, the dealer collects the cards from the previous hand off the table and sticks them at the bottom of the deck, then may optionally shuffle. (They generally don’t, which is why card-counting strategies work.) In your game, the previous hand stays on the table until the moment you’re ready to deal the next round. (Or maybe even later, because of the bug about not erasing cards, but never mind that right now.)
I did not know that! I honestly kind of forgot card counting was a thing… I’ll work on adding that! Maybe add a difficulty setting where you can either card count or have it be shuffled?
How come you don’t have your own Snap*!* account?
Oh, sorry, that was a joke. I prefer being called Joy, but this account was made for school, and I wasn’t allowed to set it to an alias. I phrased it the way I did as a kinda joke, referencing the whole “Oh, there’s no need to be professional and call me Mr. ____! That’s my father!” ex: https://www.reddit.com/r/AskAnAmerican/comments/wm3zp1/have_you_ever_actually_said_please_mr_surname_is/
I’ll work on adding that! Maybe add a difficulty setting where you can either card count or have it be shuffled?
Added!
Sorry about bet time ! You’re right !
Hmm, it’s been a long time since I’ve played with actual human beings, but my recollection is that it’s both. You have to “ante” a fixed amount to be in the game, but before the deal, you really don’t have any information on which to form an intelligent bet, so after the deal there’s another round of betting, at which people can choose to raise their bet if they like their cards, or to fold if the betting gets too costly for their taste. But maybe I’m thinking of poker?
you make an initial bet before you see your cards, (optional) you can “double” (in this case you draw only one card and increase your bet), (optional) you can split if you have 2 cards of the same value (you have to increase your bet), you can buy an insurance if the visible card of the dealer is an ace.
Oh yeah, you’re right, I was thinking of poker. :~/ In blackjack there isn’t one pot to which all players contribute, but rather individual contests against the dealer.
you can split
Speaking of, I just added that! It looks a little ugly/crowed, but I don’t know how to make it more spacious tbh…
Hi Joy, better and better!
If you want to improve it:

I suggest you to store position of each piles into a variable (just in case you want to relocate a pile earlier or ajust the position a pile)
You can use it like this:

-After you “double”, you can’t hit again… (it’s your last move)
-Split rules:
Equally well known as Twenty-One. The rules are simple, the play is thrilling, and there is opportunity for high strategy. In fact, for the expert player who mathematically plays a perfect game and is able to count cards, the odds are sometimes in that player’s favor to win.
But even for the casual participant who plays a reasonably good game, the casino odds are less, making Blackjack one of the most attractive casino games for the player. While the popularity of Blackjack dates from World War I, its roots go back to the 1760s in France, where it is called Vingt-et-Un (French for 21). Today, Blackjack is the one card game that can be found in every American casino. As a popular home game, it is played with slightly different rules. In the casino version, the house is the dealer (a “permanent bank”). In casino play, the dealer remains standing, and the players are seated. The dealer is in charge of running all aspects of the game, from shuffling and dealing the cards to handling all bets. In the home game, all of the players have the opportunity to be the dealer (a “changing bank”).
The standard 52-card pack is used, but in most casinos several decks of cards are shuffled together. The six-deck game (312 cards) is the most popular. In addition, the dealer uses a blank plastic card, which is never dealt, but is placed toward the bottom of the pack to indicate when it will be time for the cards to be reshuffled. When four or more decks are used, they are dealt from a shoe (a box that allows the dealer to remove cards one at a time, face down, without actually holding one or more packs).
Each participant attempts to beat the dealer by getting a count as close to 21 as possible, without going over 21.
It is up to each individual player if an ace is worth 1 or 11. Face cards are 10 and any other card is its pip value.
Before the deal begins, each player places a bet, in chips, in front of them in the designated area. Minimum and maximum limits are established on the betting, and the general limits are from $2 to $500.
The dealer thoroughly shuffles portions of the pack until all the cards have been mixed and combined. The dealer designates one of the players to cut, and the plastic insert card is placed so that the last 60 to 75 cards or so will not be used. (Not dealing to the bottom of all the cards makes it more difficult for professional card counters to operate effectively.)
When all the players have placed their bets, the dealer gives one card face up to each player in rotation clockwise, and then one card face up to themselves. Another round of cards is then dealt face up to each player, but the dealer takes the second card face down. Thus, each player except the dealer receives two cards face up, and the dealer receives one card face up and one card face down. (In some games, played with only one deck, the players’ cards are dealt face down and they get to hold them. Today, however, virtually all Blackjack games feature the players’ cards dealt face up on the condition that no player may touch any cards.)
If a player’s first two cards are an ace and a “ten-card” (a picture card or 10), giving a count of 21 in two cards, this is a natural or “blackjack.” If any player has a natural and the dealer does not, the dealer immediately pays that player one and a half times the amount of their bet. If the dealer has a natural, they immediately collect the bets of all players who do not have naturals, (but no additional amount). If the dealer and another player both have naturals, the bet of that player is a stand-off (a tie), and the player takes back his chips.
If the dealer’s face-up card is a ten-card or an ace, they look at their face-down card to see if the two cards make a natural. If the face-up card is not a ten-card or an ace, they do not look at the face-down card until it is the dealer’s turn to play.
The player to the left goes first and must decide whether to “stand” (not ask for another card) or “hit” (ask for another card in an attempt to get closer to a count of 21, or even hit 21 exactly). Thus, a player may stand on the two cards originally dealt to them, or they may ask the dealer for additional cards, one at a time, until deciding to stand on the total (if it is 21 or under), or goes “bust” (if it is over 21). In the latter case, the player loses and the dealer collects the bet wagered. The dealer then turns to the next player to their left and serves them in the same manner.
The combination of an ace with a card other than a ten-card is known as a “soft hand,” because the player can count the ace as a 1 or 11, and either draw cards or not. For example with a “soft 17” (an ace and a 6), the total is 7 or 17. While a count of 17 is a good hand, the player may wish to draw for a higher total. If the draw creates a bust hand by counting the ace as an 11, the player simply counts the ace as a 1 and continues playing by standing or “hitting” (asking the dealer for additional cards, one at a time).
When the dealer has served every player, the dealers face-down card is turned up. If the total is 17 or more, it must stand. If the total is 16 or under, they must take a card. The dealer must continue to take cards until the total is 17 or more, at which point the dealer must stand. If the dealer has an ace, and counting it as 11 would bring the total to 17 or more (but not over 21), the dealer must count the ace as 11 and stand. The dealer’s decisions, then, are automatic on all plays, whereas the player always has the option of taking one or more cards.
When a player’s turn comes, they can say “Hit” or can signal for a card by scratching the table with a finger or two in a motion toward themselves, or they can wave their hand in the same motion that would say to someone “Come here!” When the player decides to stand, they can say “Stand” or “No more,” or can signal this intention by moving their hand sideways, palm down and just above the table.
If a player’s first two cards are of the same denomination, such as two jacks or two sixes, they may choose to treat them as two separate hands when their turn comes around. The amount of the original bet then goes on one of the cards, and an equal amount must be placed as a bet on the other card. The player first plays the hand to their left by standing or hitting one or more times; only then is the hand to the right played. The two hands are thus treated separately, and the dealer settles with each on its own merits. With a pair of aces, the player is given one card for each ace and may not draw again. Also, if a ten-card is dealt to one of these aces, the payoff is equal to the bet (not one and one-half to one, as with a blackjack at any other time).
Another option open to the player is doubling their bet when the original two cards dealt total 9, 10, or 11. When the player’s turn comes, they place a bet equal to the original bet, and the dealer gives the player just one card, which is placed face down and is not turned up until the bets are settled at the end of the hand. With two fives, the player may split a pair, double down, or just play the hand in the regular way. Note that the dealer does not have the option of splitting or doubling down.
When the dealer’s face-up card is an ace, any of the players may make a side bet of up to half the original bet that the dealer’s face-down card is a ten-card, and thus a blackjack for the house. Once all such side bets are placed, the dealer looks at the hole card. If it is a ten-card, it is turned up, and those players who have made the insurance bet win and are paid double the amount of their half-bet - a 2 to 1 payoff. When a blackjack occurs for the dealer, of course, the hand is over, and the players’ main bets are collected - unless a player also has blackjack, in which case it is a stand-off. Insurance is invariably not a good proposition for the player, unless they are quite sure that there are an unusually high number of ten-cards still left undealt.
A bet once paid and collected is never returned. Thus, one key advantage to the dealer is that the player goes first. If the player goes bust, they have already lost their wager, even if the dealer goes bust as well. If the dealer goes over 21, the dealer pays each player who has stood the amount of that player’s bet. If the dealer stands at 21 or less, the dealer pays the bet of any player having a higher total (not exceeding 21) and collects the bet of any player having a lower total. If there is a stand-off (a player having the same total as the dealer), no chips are paid out or collected.
When each player’s bet is settled, the dealer gathers in that player’s cards and places them face up at the side against a clear plastic L-shaped shield. The dealer continues to deal from the shoe until coming to the plastic insert card, which indicates that it is time to reshuffle. Once that round of play is over, the dealer shuffles all the cards, prepares them for the cut, places the cards in the shoe, and the game continues.
Winning tactics in Blackjack require that the player play each hand in the optimum way, and such strategy always takes into account what the dealer’s upcard is. When the dealer’s upcard is a good one, a 7, 8, 9, 10-card, or ace for example, the player should not stop drawing until a total of 17 or more is reached. When the dealer’s upcard is a poor one, 4, 5, or 6, the player should stop drawing as soon as he gets a total of 12 or higher. The strategy here is never to take a card if there is any chance of going bust. The desire with this poor holding is to let the dealer hit and hopefully go over 21. Finally, when the dealer’s up card is a fair one, 2 or 3, the player should stop with a total of 13 or higher.
With a soft hand, the general strategy is to keep hitting until a total of at least 18 is reached. Thus, with an ace and a six (7 or 17), the player would not stop at 17, but would hit.
The basic strategy for doubling down is as follows: With a total of 11, the player should always double down. With a total of 10, he should double down unless the dealer shows a ten-card or an ace. With a total of 9, the player should double down only if the dealer’s card is fair or poor (2 through 6).
For splitting, the player should always split a pair of aces or 8s; identical ten-cards should not be split, and neither should a pair of 5s, since two 5s are a total of 10, which can be used more effectively in doubling down. A pair of 4s should not be split either, as a total of 8 is a good number to draw to. Generally, 2s, 3s, or 7s can be split unless the dealer has an 8, 9, ten-card, or ace. Finally, 6s should not be split unless the dealer’s card is poor (2 through 6).
Hand value: 4 or 14
The block I made to calculate does take into consideration the Ace rules, but I made it where it’ll decide which score that is chosen by itself and only display that one, as that is what the inspiration FNV did, as well as just simplifying things for those that don’t know blackjack too well.
I’m stuck…
Weird? I tested it, and pressing space still stood and caused a normal win? Either way, I went ahead and made it so, if you are delt blackjack, you will automatically win and get a little bonus (1.5 bet).
Another thing I forgot in all honesty… Though, I believe that you would have still won that without a push, as you had fewer total cards than the dealer? That could be a house rule though… I’ll get to working one that!
cards have the same value… (ex: … 10-Queen…)
I thought it was the same tier? So it would be queen - queen, face value with same face, non-pair-able with other faces or 10s. Though it seems I was wrong on that…
I’ll also see about making pos of the piles a variable, i just dont like having a lot of globals and i already have like 15, which is why I’ve stubbornly refused to do so till now.
Thank you for the suggestions!
i just dont like having a lot of globals and i already have like 15, which is why I’ve stubbornly refused to do so till now.
This is what lists are for!