I took a course in probability a few years ago and have not made my fortune in the casino yet. This program can help to count cards in single-deck blackjack and determine the odds of going bust based on your hand. The interface is quite crude :)
This is certainly not as cool as a system which is easy to
memorize, but I think it's kindof cool. Here goes:
#!/usr/bin/perl
##
#
# Card Counter : This is a basic single-deck blackjack card counter.
+ It calculates the probability
# of going bust based on the cards which have been pla
+yed. I'd love to generalize
# this some more as there are 5^12 possible states for
+ the deck when playing
# from a single deck, and this is too much for me to m
+emorize.
#
# Rohit Kumar Mehta
#
# 2003.07.17
#
##
use strict;
my @deck;
my $num;
sub showdeckstats {
my @deck=@_;
my $totalcards=0;
my @prob;
print "\t\t+---+---+---+---+---+---+---+---+---+---+---+---+---+\n";
print "card key\t| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 1
+2|\n";
print "\t\t+---+---+---+---+---+---+---+---+---+---+---+---+---+\n";
print "card value\t| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| J | Q | K |
+ A |\n";
print "\t\t+===+===+===+===+===+===+===+===+===+===+===+===+===+\n";
print "# in deck\t";
for (my $count=0; $count<=12; $count++) {
print "| $deck[$count] ";
$totalcards += $deck[$count];
}
print "|\n\t\t+---+---+---+---+---+---+---+---+---+---+---+---+---+\
+n";
print "\n\t\t\t+----+----+----+----+----+----+----+----+----+\n";
print "value of your hand\t| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
+ 20 |\n";
print "\t\t\t+====+====+====+====+====+====+====+====+====+\n";
print "prob bust next hit\t|";
for (my $val=12; $val<21; $val++) {
my $bust=0;
my $nobust=0;
for (my $card=0; $card<=12; $card++) {
my $cardval;
if ($card == 12) { $cardval=1; }
elsif ($card >7) { $cardval=10; }
else { $cardval = $card +2 }
if ( ($val + $cardval) > 21 ) { $bust=$bust+$deck[$card]; }
else { $nobust=$nobust+$deck[$card]; }
}
my $prob;
$prob = $bust/($bust+$nobust);
printf ("%1.2f|",$prob);
}
print "\n\t\t\t+----+----+----+----+----+----+----+----+----+\n";
}
#####
#
# initialize cards
#
#####
for (my $card = 0; $card <=12; $card++) {
$deck[$card]=4;
}
while (1) {
showdeckstats(@deck);
print "\nenter the key number of the card you wish to subtract: ";
$num=<stdin>;
chomp $num;
$deck[$num]--;
}