top of page
Search
  • Writer's picturedavidcarew19

HTML+JS for a Blackjack Basic Strategy Drill App

<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>


 

Copy-paste the above. Save it to your hard drive under the name: "Bstr-Ref-Drill.html". Double-click Bstr-Ref-Drill.html on your local drive, activating a one-page Web application which drills you on Blackjack Basic strategy, as you enter individual hands into a query box and press the "DO:" button. The "Rule:" text box has 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.


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.

5 views0 comments

Recent Posts

See All

There are Three...

There are 3 Dave Carew's in my life: There is the one I try not to be, the one I wish I was, and the one that I actually am. Occasionally (always) I find it in my heart to wish that the one I am, was

After You have Weathered the Storm...

You won't be the same person you were before the storm. From certain perspectives, this could be precisely what the storm was all about.

Post: Blog2_Post
bottom of page