top of page
Search

HTML+JS for a Blackjack Basic Strategy Drill App

  • Writer: davidcarew19
    davidcarew19
  • Apr 28, 2024
  • 5 min read

Updated: Oct 24, 2024

<html>

<!--

Bstr-Ref-Drill-v7.html

This one-page, self-contained BlackJack learning HTML with embeddedded JavaScript

is copyright � David Carew, 2008. It is associated with the book authored by

David Carew, entitled "Winning Recreational BlackJack". All rights reserved.

-->

<head>

<title>Winning Recreational Blackjack - HAVE/DO Rules: Learning Drill ver. 7</title>

<!--

A form named bjdrildata is re-calculated and re-displayed when DO button is pushed, based upon a

random selection of hands from guide[hand]. Note guide[] is associative array. We "fix" that for

random selection via a JS function from the Diffic-Hands-Drill.html JS support code...

increm dev here:

a. remove the HAVE: prompt for yrhand yalue

b. wire the yrhand value to some valid input AND

c. validate the DO button still works w/o HAVE prompt

THEN

animate random assignment of yrhand value in the bjdrildata form

make the DO button react to the random assignment behaving as it does in v6 where user input

assigns value.

-->

<SCRIPT LANGUAGE="JavaScript1.3">

function calculate() {

var hand = document.bjdrildata.yrhand.value.toUpperCase();

var guide ={ '5':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'6':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'7':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'8':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'9':{adv:'Dbl(3-6) else H',mnem:"Nine 9 doubles down on TREY, else HIT would be the play."},

'10':{adv:'Dbl(2-9) else H',mnem:"Ten should DOUBLE on 2-9 wide, else HIT your 10 to turn the tide."},

'11':{adv:'Hit(Ace) else Dbl',mnem:"Eleven is easy; always DOUBLE except for Ace-y."},

'12':{adv:'Stand(4-6) else H',mnem:"Hard 12 STANDs on QUAD's; else HIT for odds."},

'13':{adv:'Stand(2-6) else H',mnem:"Young teens STAND on DEUCE else HIT the juice."},

'14':{adv:'Stand(2-6) else H',mnem:"Young teens STAND on DEUCE else HIT the juice."},

'15':{adv:'Stand(2-6) else H',mnem:"Young teens STAND on DEUCE else HIT the juice."},

'16':{adv:'Stand(2-6) else H',mnem:"Young teens STAND on DEUCE else HIT the juice."},

'17':{adv:'Stand Always',mnem:"On 17 thru 20 --you've got plenty (Always STAND)."},

'18':{adv:'Stand Always',mnem:"On 17 thru 20 --you've got plenty (Always STAND)."},

'19':{adv:'Stand Always',mnem:"On 17 thru 20 --you've got plenty (Always STAND)."},

'20':{adv:'Stand Always',mnem:"On 17 thru 20 --you've got plenty (Always STAND)."},

'21':{adv:'Stand Always',mnem:"On 17 thru 20 --you've got plenty (Always STAND)."},

'23':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."}, //same as 5 above

'24':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'25':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'26':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'27':{adv:'Dbl(3-6) else H',mnem:"Nine 9 doubles down on TREY, else HIT would be the play."},

'28':{adv:'Dbl(2-9) else H',mnem:"Ten should DOUBLE on 2-9 wide, else HIT your 10 to turn the tide."},

'29':{adv:'Hit(Ace) else Double',mnem:"Eleven is easy; always DOUBLE except for Ace-y."},

'32':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'34':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'35':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'36':{adv:'Dbl(3-6) else H',mnem:"Nine 9 doubles down on TREY, else HIT would be the play."},

'37':{adv:'Dbl(2-9) else H',mnem:"Ten should DOUBLE on 2-9 wide, else HIT your 10 to turn the tide."},

'38':{adv:'Hit(Ace) else Dbl',mnem:"Eleven is easy; always DOUBLE except for Ace-y."},

'39':{adv:'Stand(4-6) else H',mnem:"Hard 12 STANDs on QUAD's; else HIT for odds."},

'42':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'43':{adv:'Hit Always',mnem:"Always plays are common sense/ Always do and don't be dense."},

'45':{adv:'Dbl(3-6) else H',mnem:"Nine 9 doubles down on TREY, else HIT would be the play."},

'46':{adv:'Dbl(2-9) else H',mnem:"Ten should DOUBLE on 2-9 wide, else HIT your 10 to turn the tide."},

'47':{adv:'Hit(Ace) else Double',mnem:"Eleven is easy; always DOUBLE except for Ace-y."},

'48':{adv:'Stand(4-6) else H',mnem:"Hard 12 STANDs on QUAD's; else HIT for odds."},

'49':{adv:'Stand(2-6) else H',mnem:"Young teens STAND on DEUCE else HIT the juice."},

'A2':{adv:'Dbl(5-6) else H',mnem:"Acey-2 an' Acey-3: Double on QUINT or HIT's the hint"},

'2A':{adv:'Dbl(5-6) else H',mnem:"Acey-2 an' Acey-3: Double on QUINT or HIT's the hint"},

'A3':{adv:'Dbl(5-6) else H',mnem:"Acey-2 an' Acey-3: Double on QUINT or HIT's the hint"},

'A4':{adv:'Dbl(4-6) else H',mnem:"Acey-4 an' Acey-5: DOUBLE QUAD or HIT n strive"},

'A5':{adv:'Dbl(4-6) else H',mnem:"Acey-4 an' Acey-5: DOUBLE QUAD or HIT n strive"},

'A6':{adv:'Dbl(3-6) else H',mnem:"Acey-6 DOUBLEs on TREY; else HITZ the way"},

'A7':{adv:'Dbl(3-6), S(2,7,8), H(9,X,A)',mnem:"Acey-7 is a triple place: Double TREY; Stand around TREY else HIT the 9, 10, Ace."},

'A8':{adv:'Stand Always',mnem:"Acey-8 and Acey-9: always STAND (this needs no rhyme)."},

'A9':{adv:'Stand Always',mnem:"Acey-8 and Acey-9: always STAND (this needs no rhyme)."},

'22':{adv:'PairSplit (2-7) else H',mnem:"Pair 2's 'n 3's 'n 7's: all DEUCE-HI splits; else hits."},

'44':{adv:'PairSplit (2-7) else H',mnem:"Pair 2's 'n 3's 'n 7's: all DEUCE-HI splits; else hits."},

'33':{adv:'PairSplit (2-7) else H',mnem:"Pair 2's 'n 3's 'n 7's: all DEUCE-HI splits; else hits."},

'44':{adv:'Hit Always = play as 8',mnem:"Pair 4's/pair 5's: Don't split them; play as 8 or 10."},

'55':{adv:'Dbl(2-9) else H = play as 10',mnem:"Pair 4's/pair 5's: Don't split them; play as 8 or 10."},

'66':{adv:'PairSplit (2-6) else H',mnem:"Pair the 6's; DEUCE is split-ez; else you HITs-ez."},

'77':{adv:'PairSplit (2-7) else H',mnem:"Pair 2's 'n 3's 'n 7's: all DEUCE-HI splits; else hits."},

'88':{adv:'PairSplit Always',mnem:"Always plays in Pairs--Split Eight's and Aces / Stand on faces."},

'99':{adv:'Stand(7,A,X) else P',mnem:"Pair 9's--Stand 7AX is fine; else split those nines."},

'AA':{adv:'PairSplit Always',mnem:"Always plays in Pairs--Split Eight's and Aces / Stand on faces."},

'XX':{adv:'Stand Always',mnem:"Always plays in Pairs--Split Eight's and Aces / Stand on faces."},

'FF':{adv:'Stand Always',mnem:"Always plays in Pairs--Split Eight's and Aces / Stand on faces."}

}

// ignore some invalid input

if (hand.length > 2) hand = hand.substr(0,2);

try {

if (guide[hand].adv != null) {

document.bjdrildata.rule.value = guide[hand].adv;

document.bjdrildata.mnemo.value = guide[hand].mnem;

document.bjdrildata.yrhand.value = hand;

document.bjdrildata.yrhand.focus();

}

}catch (err) {

// catch TypeError if adv or mnem for the input is undefined

// action is to clear the input and output textarea's

// and allow customer to try again...

document.bjdrildata.yrhand.value = "";

document.bjdrildata.rule.value = "";

document.bjdrildata.mnemo.value = "";

document.bjdrildata.yrhand.focus();

}

}

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.3">

function handle(e){

// attempt to generate answer when keypress==Enter key

if(e.keyCode === 13){

calculate();

}

return false;

}

</SCRIPT>

</head>

<body bgcolor="Cornsilk" >

<!--

This is an HTML form for a cut at TSPTTCW, for a BJ BS drill

program.

-->

<FORM NAME="bjdrildata" action="#">

<TABLE>

<TH><TD><BIG><B>Ver 7 Drill: Hand You HAVE (in Blackjack shorthand e.g. 'A4' or '17'):</B></BIG></TD></TH>

<TR>

<TD>H A V E :</TD>

<TD><INPUT TYPE=text NAME=yrhand SIZE=2 tabindex="1" value="17"></TD>

</TR>

<TR>

<TD COLSPAN=3>

<BIG><B>

<INPUT TYPE=button VALUE="D O :" onClick="calculate() " onkeypress="handle(event)">

</B></BIG>

<TR>

<TD colspan="1">

<TD>What action you must DO (the Rule)&#32 for correct Basic Strategy and a mnemonic to remember it.</TD></TR>

<TR>

<TD>&#32</TD>

<TD>Rule:</TD>

</TR><TR>

<TD>&#32</TD>

<TD colspan="3"><INPUT TYPE=text NAME=rule SIZE=24></TD>

</TR>

<TR>

<TD>&#32</TD>

<TD>Mnemonic: </TD>

</TR><TR>

<TD>&#32</TD>

<TD colspan="2"><INPUT TYPE=text NAME=mnemo SIZE=84></TD>

</TR><TR>

<TD>

</TABLE>

</FORM>

<span id=span1 style="font-size:16pt"> </span>

</body>

</html>


Instructions to save and use this code on your (Windows) PC:

Copy-paste the above. Save it to your hard drive by pasting the code above into an empty copy of Notepad. Then use the Notepad "save as" function to save the code above onto your hard drive. Assign a name including the file extension ".html". For example, you could use the name: "Bstr-Ref-Drill.html". Once the code above is saved, Double-click Bstr-Ref-Drill.html on your local drive, activating a one-page Web application which drills you on casino Blackjack Basic Strategy-- You enter individual hands into the "HAVE" query box and click the "DO:" button. The "Rule:" text box and the "Mnemonic:" text box are filled in with the correct Basic Strategy you must take for the hand you enter in HAVE query box. The "Rule" text box displays ranges that refer to the dealer's visible "up card"-- For example Dbl(3-6) means Double Down when the Dealer's up card is 3 or 4 or 5 or 6, that is when the dealer's card in in the range of 3 through 6.


Use a basic strategy "cheat sheet" to anticipate and memorize the DO actions for each hand as you drill. When you can answer correctly 100 percent of the time without referencing the cheat sheet, before confirming with the DO button, then you know correctly how to play the casino game of Blackjack.

 
 
 

Recent Posts

See All
Announcement Too Late

Susan K. Carew (my wife) published a book, entitled "There's a Piano in a Meadow", subtitled "And Other Family Stories". The book is...

 
 
 

ความคิดเห็น


  • Facebook
  • Twitter
  • LinkedIn

©2019 by DavidCarew. Proudly created with Wix.com

bottom of page