Jump to content

[Perl] Crappy Blackjack Betting Strat


Recommended Posts

If you use the HaxMe discord, you may know that there's a bot channel where mostly Aeo and I play blackjack. We've both held the top of the leaderboard before a few times, but recently I accidentally lost everything in a crazy gamble and I need to make everything back from scratch. For that reason, I needed to come up with a strategy, and the first thing I thought of was that for every successive game you should play for the amount that you've lost so far. The assumption is that as long as you have enough money, you're unlikely to just keep losing forever, and will eventually get back to even (this is a bad assumption, however, as it's exactly how I lost everything). From a math modeling perspective, if n is the amount of turns until you run out of money then you want to maximize n.

So this is just a crappy program that I whipped up in about 5 minutes to print the betting numbers. I'll probably update it more with some actual gameplay strategies and also the ability to recalculate the bets in the case of a double-down.

##!/usr/bin/perl -w
use strict;

print "Enter the starting bet:\n";
chomp(my $lost = <STDIN>);
for(my $i = 1; $i <= 10; $i++){
	print $i."\t".$lost."\n";
	$lost += $lost;


Link to comment
Share on other sites

  • 3 weeks later...

Shouldnt there be some kind of game theory method of coming up with a play stratedgy? I don't know about the programming of the discord bot. But, if it played with a "fair deck"" (cards are not just randomly generated from thin air but there is an actual digital representation of a deck of cards), a method such as digital way of counting cards would seem better. Although it may not work if it isn't a "fair deck"

Link to comment
Share on other sites

It does use a fair deck (or rather 3 fair decks). I would like to add a way of counting cards, but I'm reluctant because I think I would have to manually tell it which cards have been played, and it uses the same deck regardless of who is playing so I'd also have to go back and enter the cards that appeared while others played.

For that reason, the best strategy that I have so far is just playing enough games in a row to recuperate losses before going broke, while potentially "doubling down" when appropriate (however, this is risky, especially the later in the series you do it).

I may also teach it to use a specific generic strategy such as this:
Blackjack Strategy Charts for the specific tables you play on

Link to comment
Share on other sites

I would have to look into how counting cards I work. If I remember, Jack, Queen, King and Ace are counted as like 10, then each face card as its own value. Instead of tracking specific cards, what about keeping the count in an array at each index that the value would be. Then just iterate through to get the average.

Or if you need to know each card that was previously played, you could roll a queue and if you only need so many of the previous cards, keep the size limited. What would be interested would be to look into, the most efficient number of previous cards to use during a count to be able to predict. Like is there a certain number of total cards into a session where having the information is no longer as relevant?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...