Basic Organizatio

Each hand stores a list of cards, a wager on that hand, and a list of the plays that have occured on that hand.

e.g.Hand={{1,2,13},12,{"Sp", "D"}}  denotes a hand cosnsiting of a {Ace, 2,King} with a 12 dollar wager. An initial pair of Aces was split and become an {Ace, 2} and the bet was then doubled to become with the new card being a King.

Card counting is included in the function “Deal” that deals new cards.

Deal takes in and returns a Hand, a Shoe, a Stack, and a Count.

The basic strategy function takes in a Hand with a Dealer card.  It returns one of the following strings.

“H”, “S”,”Sp”,”DH”, “Su”, “DS”

described in the wiki page.

Basic  Functions

This looks good.  Nice and simple.

Card Counting Functions

I made up my own count.  It keeps track of the#  of Aces and Ten Count cards that have been seen.

(*InitializeCount[]:= {0,0};
UpdateCount[count_, card_]:= Switch[Min[card,10],
1,count+{-1,1},
10,count+{-1,0},
2,count+{1,0},
3,count+{1,0},
4,count+{1,0},
5,count+{1,0},
6,count+{1,0},
_, count]*)

InitializeCount[]:= {0,0};
UpdateCount[count_, card_]:= Switch[Min[card,10],
1,   count+{1,0},
10, count+{0,1},
_,count]

count=InitializeCount[];
count=UpdateCount[count,12];
count=UpdateCount[count,1];
count=UpdateCount[count,2];
count

NewShoe

Shuffles a new Shoe of cards up out of a specified numerb of standard decks.

NewShoe[numberofdecks_]:=RandomSample[Flatten[Table[i,{i,1,13},{4},{numberofdecks}],2]]

NewShoe[2]

Deals One card at a time and updates the count.

ShuffleBarrier is the point when the Dealer reshuffles the deck. It reads in a Hand, a shoe, and a count and updates them all. In the real world we do not see the dealer card untill the end.

Deal[{Hand_,shoe_,count_}, numberofdecks_]:=Module[
{ShuffleBarrier=10,TempNewShoe=shoe,TempNewCount=count,TempNewHand=Hand,Card},
If[Length[shoe]<ShuffleBarrier,
TempNewShoe=NewShoe[numberofdecks]; TempNewCount=InitializeCount[]
];
Card=TempNewShoe[[-1]];
TempNewShoe=Drop[TempNewShoe,-1];
TempNewCount=UpdateCount[TempNewCount, Card];
AppendTo[TempNewHand[[1]],Card];
{TempNewHand,TempNewShoe,TempNewCount}
]

NumberOfShoes=2;
shoe=NewShoe[NumberOfShoes]
count=InitializeCount[];
Hand={{1,4},12,{}};
Do[
{Hand,shoe,count}=Deal[{Hand,shoe,count},NumberOfShoes],
{2}]
{Hand,shoe,count}

Hand scoring functions

Takes in a hand (list of cards) counts the number of aces and computes the highest possible score  less than or equal to 21.  It returns the best score and a flag if the the best score is hard or soft.

ScoreHand[HandIn_]:= Module[
{n,Hand=HandIn,AceCount,BaseScore,Score},
(* Replaces face cards with 10s *)
Hand=Hand/.{11->10,12->10,13->10};
(* Counts Aces *)
AceCount=Count[Hand,1];
(* Base Score Counts all Aces as 1 *)
BaseScore=Sum[Hand[[n]],{n,1,Length[Hand]}];
(* Computes the largest of the possible scores that is 21 or less *)
Score=Max[Select[BaseScore+10*Range[0, AceCount],#<=21&]];
{Score,If[BaseScore==Score,"Hard","Soft"]}
]

I think this works, but note what this does if you bust!

ScoreHand[{1,1,1,1,2}]
ScoreHand[{1,1,1,1,13,4}]
ScoreHand[{1,1,1,1,13,8}]
ScoreHand[{13,4,8}]

The basic strategy has some special options for splitting pairs. The following checks for a pair. According to the wiki page some casinos allow you to split {11,12} and some do not.

IsPair[Hand_]:=And[Length[Hand]==2,Hand[[1]]==Hand[[2]]]

Hand={12,11};
IsPair[Hand]

Basic Strategy functions

Implements the basic strategy as described on the wiki page 
  http://en.wikipedia.org/wiki/Blackjack#Basic_strategy.
The strategy is described in three tables: hard, soft, and pairs.

The first thing to make is a splitter.

BasicStrategySplitter[Hand_,DealerCard_]:= Module[
{Score,Flag,Play},
{Score,Flag}=ScoreHand[Hand];
Which[
IsPair[Hand],    Play=PairsFunction[Hand,DealerCard],
Flag=="Soft",  Play=SoftFunction[{Score,Flag}, DealerCard],
Flag=="Hard",  Play=HardFunction[{Score,Flag}, DealerCard]
];
Play
]

The second thing to do is make the three functions up above.

Pairs Function

Clear[PairsFunction]
PairsFunction[Hand_, DealerCard_]:= Module[
{PairsTable,Card},
PairsTable=(({{"SP", "SP", "SP", "SP", "SP", "SP", "SP", "SP", "SP", "SP"}, {"H", "SP", "SP", "SP", "SP", "SP", "SP", "H", "H", "H"}, {"H", "SP", "SP", "SP", "SP", "SP", "SP", "H", "H", "H"}, {"H", "H", "H", "H", "SP", "SP", "H", "H", "H", "H"}, {"H", "DH", "DH", "DH", "DH", "DH", "DH", "DH", "DH", "H"}, {"H", "SP", "SP", "SP", "SP", "SP", "H", "H", "H", "H"}, {"H", "SP", "SP", "SP", "SP", "SP", "SP", "H", "H", "H"}, {"SP", "SP", "SP", "SP", "SP", "SP", "SP", "SP", "SP", "SP"}, {"S", "SP", "SP", "SP", "SP", "SP", "S", "SP", "SP", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}}));
Card=Hand[[1]]/.{11->10,12->10,13->10};
PairsTable[[Card,DealerCard/.{11->10,12->10,13->10}]]
]

Checking if this is correct.

TableForm[
Table[ PairsFunction[{i,i},d],
{i,1,13},{d,1,13}],
TableHeadings->{
{"A-A","2-2","3-3","4-4","5-5","6-6","7-7","8-8","9-9","10-10","11-11","12-12","13-13"},Automatic}
]

Soft Function

For consistency I added a row for 21 to this table.

SoftFunction[{Score_,Flag_},DealerCard_]:=Module[
{SoftTable},
SoftTable=(({{"H", "H", "H", "H", "DH", "DH", "H", "H", "H", "H"}, {"H", "H", "H", "H", "DH", "DH", "H", "H", "H", "H"}, {"H", "H", "H", "DH", "DH", "DH", "H", "H", "H", "H"}, {"H", "H", "H", "DH", "DH", "DH", "H", "H", "H", "H"}, {"H", "H", "DH", "DH", "DH", "DH", "H", "H", "H", "H"}, {"H", "S", "DS", "DS", "DS", "DS", "S", "S", "H", "H"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}}));
SoftTable[[Score-11,DealerCard/.{11->10,12->10,13->10}]]
]

Checking

TableForm[
Table[ SoftFunction[{SoftTotal,"Soft"},d],
{SoftTotal,13,21},{d,1,13}],
TableHeadings->{{"A2","A3","A4","A5","A6","A7","A8","A9","A10"},Automatic}
]

SoftFunction[{20,"Soft"},1]

Hard Function

For consistency I added a row for 21 to this table.

HardFunction[{Score_,Flag_},DealerCard_]:=Module[
{HardTable},
HardTable=(({{"H", "H", "H", "H", "H", "H", "H", "H", "H", "H"}, {"H", "H", "H", "H", "H", "H", "H", "H", "H", "H"}, {"H", "H", "H", "H", "H", "H", "H", "H", "H", "H"}, {"H", "H", "H", "H", "H", "H", "H", "H", "H", "H"}, {"H", "H", "DH", "DH", "DH", "DH", "H", "H", "H", "H"}, {"H", "DH", "DH", "DH", "DH", "DH", "DH", "DH", "DH", "H"}, {"H", "DH", "DH", "DH", "DH", "DH", "DH", "DH", "DH", "DH"}, {"H", "H", "H", "S", "S", "S", "H", "H", "H", "H"}, {"H", "S", "S", "S", "S", "S", "H", "H", "H", "H"}, {"H", "S", "S", "S", "S", "S", "H", "H", "H", "H"}, {"H", "S", "S", "S", "S", "S", "H", "H", "H", "SU"}, {"SU", "S", "S", "S", "S", "S", "H", "H", "SU", "SU"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}, {"S", "S", "S", "S", "S", "S", "S", "S", "S", "S"}}));
HardTable[[Score-4,DealerCard/.{11->10,12->10,13->10}]]
]

Checking

TableForm[
Table[ HardFunction[{HardTotal,"hard"},d],
{HardTotal,5,21},{d,1,13}],
TableHeadings->{Range[5,21],Automatic}
]

Testing Basic Strategy

Check this.  Is the thing below really correct.

Hand={10,1};
DealerCard=3;
BasicStrategySplitter[Hand,DealerCard]

Hand={10,6};
DealerCard=1;
BasicStrategySplitter[Hand,DealerCard]

Hand={6,6};
DealerCard=3;
BasicStrategySplitter[Hand,DealerCard]

Game play functions

It needs to do the following
({{"H", Hit, Adds a card to the hand}, {"DH", Doubles and Hits, Adds a card, adjusts bet, announces done.}, {"DS", Doubles or Stay, DH if two cards, Stay if more }, {"S", Stay, Announces dones}, {"Su", Surrenders, Gives up the hand adjusts bet}, {"SP", Splits, Splits the hand and deals, adjusts bets.}})

Just realized that the rules mean that somethings need to be Blocked. Sometimes you can not hit after a split etc.

Play[{{Hand_,CurrentWager_},{CurrentStack_,CurrentDeck_,CurrentCount_}},DealerCard_,Play_,NumberOfDecks_]:=Module[
{NewHand,NewHandSp, NewWager,NewStack,NewDeck,NewCount},
Switch[Play,
"H", {NewHand,NewDeck,NewCount}=Deal[{Hand,CurrentDeck,CurrentCount},NumberOfDecks];
	  {{NewHand,CurrentWager},CurrentStack},
"DH",{NewHand,NewDeck,NewCount}=Deal[{Hand,CurrentDeck,CurrentCount},NumberOfDecks];
	    {{NewHand, 2*CurrentWager}, CurrentStack -CurrentWager},
"Su",{{{},0}, CurrentStack+CurrentWager/2},
"Sp",{NewHand,    NewDeck,NewCount}=Deal[{{Hand[[1]]},CurrentDeck,CurrentCount},NumberOfDecks];
	   {NewHandSp,NewDeck,NewCount}=Deal[{{Hand[[1]]},CurrentDeck,CurrentCount},NumberOfDecks];
	  {{{NewHand,CurrentWager},{NewHandSp,CurrentWager}}, CurrentStack-CurrentWager},
"S",   {{Hand,CurrentWager},CurrentStack}
]
]

Hand={10,9};
DealerCard=1;
BasicStrategySplitter[Hand,DealerCard]
SoftFunction[{20,"Soft"},1]

?HardFunction
?SoftFunction

Break

PlayerFunction[player1Hand_,d1_]:=Module[
{D1=d1,BestCount,SoftAces},
{BestCount,SoftAces}=ScoreHand[player1Hand];

Which[
player1Hand[[1]]==player1Hand[[2]]&&Length[player1Hand]==2,
PairsFunction[player1Hand,D1],

SoftAces>0,
SoftFunction[player1Hand,D1],

True,HardFunction[player1Hand,D1]
]]

(* HiLoCount *)
CardCount[cardsplayed_,count_,deck_]:=Module[
{cards=cardsplayed/.{1->-1,2->1,3->1,4->1,5->1,6->1,7->0,8->0,9->0,10->-1,11->-1,12->-1,13->-1}},
Floor[((count+Sum[cards[[i]],{i,1,Length[cards]}])/(Length[deck]/52))]
]

DecideBet[count_,favorablecount_,totalcash_]:=Module[{bet},
Which[
count≥favorablecount&&totalcash≥10,bet=10,
count≥favorablecount&&totalcash≥1,bet=1,
count<favorablecount&&totalcash≥1,bet=1,
True,bet=0;Print["bankrupt"];bet
]
]

(* hit on soft 17 *)
DealerDecision[dealerhand_,deck_,count_,decksinshoe_]:=Module[
{newdealerhand,cardtodeal,newdeck},
{cardtodeal,newdeck}=Deal[1,deck,count,decksinshoe];

If[ScoreHand[dealerhand][[1]]<17∨And[ScoreHand[dealerhand][[1]]==17,ScoreHand[dealerhand][[2]]>0],

newdealerhand=Join[dealerhand,cardtodeal];{newdealerhand,newdeck},
{dealerhand,deck}]]

(*input {player hand, dealer face up card, deck}
output {decision, modified player hand, modified deck}*)

(*PlayerDecision[Player1hand_,d1_,deck_]:=Module[
{cardtodeal,newdeck,newPlayer1hand},
{cardtodeal,newdeck}=Deal[1,deck];
Which[

PlayerFunction[Player1hand,d1]=="H",
	newPlayer1hand=Join[Player1hand,cardtodeal];{"H",newPlayer1hand,newdeck},

PlayerFunction[Player1hand,d1]=="S",
	{"S",Player1hand,deck},

PlayerFunction[Player1hand,d1]=="SU",(*if not first turn then H*)
	{"SU",Player1hand,deck},

PlayerFunction[Player1hand,d1]=="DH",
	newPlayer1hand=Join[Player1hand,cardtodeal];{"DH",newPlayer1hand,newdeck},

PlayerFunction[Player1hand,d1]=="DS",
	{"DS",Player1hand,deck},

PlayerFunction[Player1hand,d1]=="SP",
	{"Split: this is not completed",Player1hand,deck}
]];*)

(* maxbet=10 minbet=1, take maxbet when count ≥ favorablecount
	Returns:{{{newPlayer1hand,bet,"H or S"}, {second hand data if applicable},newdeck,newcount,newtotalcash}*)
PlayerDecision[Player1hand_,dealerhand_,deck_,Count_,decksinshoe_,totalcash_,favorablecount_]:=Module[
{cardtodeal,newdeck,newPlayer1hand,d1,bet,newcount,newtotalcash,count},
{cardtodeal,newdeck,count}=Deal[1,deck,Count,decksinshoe];d1=dealerhand[[1]];

bet=DecideBet[count,favorablecount,totalcash];

Which[

PlayerFunction[Player1hand,d1]=="H",
	newPlayer1hand=Join[Player1hand,cardtodeal];
	newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];
	newtotalcash=totalcash-bet;
{{newPlayer1hand,bet,"H"},newdeck,newcount,newtotalcash},

PlayerFunction[Player1hand,d1]=="S",
	newcount=CardCount[Join[Flatten[{Player1hand,d1}]],count,deck];
	newtotalcash=totalcash-bet;
{{Player1hand,bet,"S"},deck,newcount,newtotalcash},

PlayerFunction[Player1hand,d1]=="SU",(*if not first turn then H*)
	Which[
	Length[Player1hand]==2,
		newcount=CardCount[Join[Flatten[{Player1hand,d1}]],count,deck];
		newtotalcash=totalcash-.5bet;
		newPlayer1hand={0,0};
		{{newPlayer1hand,bet,"S"},deck,newcount,newtotalcash},
	True,
		newPlayer1hand=Join[Player1hand,cardtodeal];
		newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];
		newtotalcash=totalcash-bet;
		{{newPlayer1hand,bet,"H"},newdeck,newcount,newtotalcash}
	],

PlayerFunction[Player1hand,d1]=="DH",
	newPlayer1hand=Join[Player1hand,cardtodeal];
	newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];	
	Which[
	2bet≤totalcash&&Length[Player1hand]==2,
		newtotalcash=totalcash-2bet;
		{{newPlayer1hand,2bet,"S"},newdeck,newcount,newtotalcash},
	True,
		newtotalcash=totalcash-bet;
		{{newPlayer1hand,bet,"H"},newdeck,newcount,newtotalcash}
	],

PlayerFunction[Player1hand,d1]=="DS",
	Which[
	2bet≤totalcash&&Length[Player1hand]==2,
		newPlayer1hand=Join[Player1hand,cardtodeal];
		newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];		
		newtotalcash=totalcash-2bet;
		{{newPlayer1hand,2bet,"S"},newdeck,newcount,newtotalcash},
	True,
		newcount=CardCount[Join[Flatten[{Player1hand,d1}]],count,deck];
		newtotalcash=totalcash-bet;
		{{Player1hand,bet,"S"},deck,newcount,newtotalcash}
	],

PlayerFunction[Player1hand,d1]=="SP",
	{{Player1hand,bet,"SP"},deck,newcount,newtotalcash}
(* ? *)
]
]

AAS Mess

Big picture:  I have stuff that gives me a decision string which is one of the list {”H”,”S”,“DH”,”SP”,”SU”}. They mean Hit, Stand, Double Hit,   Split, and Surrender. I need to make the player do the correct thing for each hand.  The player needs to modify bets (and corresponding remaining cash), and hands she is playing.

Some casinos some special rules about resplitting and surrendering but I am going to ignore these.

Note: Surrendering involves giving up a hand. Splitting involves increasing the number of hands.  Sometimes players play mulitple hands against the dealer.  

Note Well:  I think the easiest way to do this is make the input a set of hands which will include the current bet on each hand.

SurrenderSplit[ {ListOfHands_, DealerUpCard_, Deck_,
 {CurrentCount_, FavorableCount_, DecksInShoe_},  Stack_}]:= Module[
{Hand,i,Decision,n=Length[ListOfHands]},
Table[
Hand=ListOfHands[[i]];
Decision=PlayerFunction[Hand,DealerUpCard];
Switch[Decision,
"SU", Hand={},
"Sp", (*SplitHand" *),
_, Hand],
{i,1,n}]
]

Deal[numberofcards_,shoe_,count_,decksinshoe_]:=Module[
{newshoe,newcount},
If[numberofcards>Length[shoe]-10,
newshoe=Shoe[decksinshoe];newcount=0;
{newshoe[[-numberofcards;;-1]],Drop[newshoe,-numberofcards],newcount},
{shoe[[-numberofcards;;-1]],Drop[shoe,-numberofcards],count}
]]

Deal[deck

Input: 		PlayerDecision[ {{Hand1, Hand2,…}, DealerUpCard, Deck, {CurrentCount, FavorableCount, DecksInShoe},  CashStash_]

Output: 	{{Hand1,Hand2,…},DealerUpCard, Deck, {CurrentCount, FavorableCount, DecksInShoe}, CashStash}

I am going to do this by making a decision on a single hand. That is going to return a list of hands.  The list will be empty if the player has Surrendered and have two hands if the player has Split. I will then combine this into a function that plays a list of hands.

?Switch

PlayerDecisionSingle[ {
Hand_, DealerUpCard_, Deck_,
 {CurrentCount_, FavorableCount_, DecksInShoe_},  Stack_}]:= Module[
{Decision},
Decision=PlayerFunction[Hand,DealerUpCard];
Hands=Switch[Decision,
"Su",{},
"Sp",{},
_, {Hand}];
]

(*input {player hand, dealer face up card, deck}
output {decision, modified player hand, modified deck}*)

(*PlayerDecision[Player1hand_,d1_,deck_]:=Module[
{cardtodeal,newdeck,newPlayer1hand},
{cardtodeal,newdeck}=Deal[1,deck];
Which[

PlayerFunction[Player1hand,d1]=="H",
	newPlayer1hand=Join[Player1hand,cardtodeal];{"H",newPlayer1hand,newdeck},

PlayerFunction[Player1hand,d1]=="S",
	{"S",Player1hand,deck},

PlayerFunction[Player1hand,d1]=="SU",(*if not first turn then H*)
	{"SU",Player1hand,deck},

PlayerFunction[Player1hand,d1]=="DH",
	newPlayer1hand=Join[Player1hand,cardtodeal];{"DH",newPlayer1hand,newdeck},

PlayerFunction[Player1hand,d1]=="DS",
	{"DS",Player1hand,deck},

PlayerFunction[Player1hand,d1]=="SP",
	{"Split: this is not completed",Player1hand,deck}
]];*)

(* maxbet=10 minbet=1, take maxbet when count ≥ favorablecount
	Returns:{{{newPlayer1hand,bet,"H or S"}, {second hand data if applicable},newdeck,newcount,newtotalcash}*)
PlayerDecision[Player1hand_,dealerhand_,deck_,Count_,decksinshoe_,totalcash_,favorablecount_]:=Module[
{cardtodeal,newdeck,newPlayer1hand,d1,bet,newcount,newtotalcash,count},
{cardtodeal,newdeck,count}=Deal[1,deck,Count,decksinshoe];d1=dealerhand[[1]];

bet=DecideBet[count,favorablecount,totalcash];

Which[

PlayerFunction[Player1hand,d1]=="H",
	newPlayer1hand=Join[Player1hand,cardtodeal];
	newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];
	newtotalcash=totalcash-bet;
{{newPlayer1hand,bet,"H"},newdeck,newcount,newtotalcash},

PlayerFunction[Player1hand,d1]=="S",
	newcount=CardCount[Join[Flatten[{Player1hand,d1}]],count,deck];
	newtotalcash=totalcash-bet;
{{Player1hand,bet,"S"},deck,newcount,newtotalcash},

PlayerFunction[Player1hand,d1]=="SU",(*if not first turn then H*)
	Which[
	Length[Player1hand]==2,
		newcount=CardCount[Join[Flatten[{Player1hand,d1}]],count,deck];
		newtotalcash=totalcash-.5bet;
		newPlayer1hand={0,0};
		{{newPlayer1hand,bet,"S"},deck,newcount,newtotalcash},
	True,
		newPlayer1hand=Join[Player1hand,cardtodeal];
		newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];
		newtotalcash=totalcash-bet;
		{{newPlayer1hand,bet,"H"},newdeck,newcount,newtotalcash}
	],

PlayerFunction[Player1hand,d1]=="DH",
	newPlayer1hand=Join[Player1hand,cardtodeal];
	newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];	
	Which[
	2bet≤totalcash&&Length[Player1hand]==2,
		newtotalcash=totalcash-2bet;
		{{newPlayer1hand,2bet,"S"},newdeck,newcount,newtotalcash},
	True,
		newtotalcash=totalcash-bet;
		{{newPlayer1hand,bet,"H"},newdeck,newcount,newtotalcash}
	],

PlayerFunction[Player1hand,d1]=="DS",
	Which[
	2bet≤totalcash&&Length[Player1hand]==2,
		newPlayer1hand=Join[Player1hand,cardtodeal];
		newcount=CardCount[Join[Flatten[{Player1hand,cardtodeal,d1}]],count,newdeck];		
		newtotalcash=totalcash-2bet;
		{{newPlayer1hand,2bet,"S"},newdeck,newcount,newtotalcash},
	True,
		newcount=CardCount[Join[Flatten[{Player1hand,d1}]],count,deck];
		newtotalcash=totalcash-bet;
		{{Player1hand,bet,"S"},deck,newcount,newtotalcash}
	],

PlayerFunction[Player1hand,d1]=="SP",
	{{Player1hand,bet,"SP"},deck,newcount,newtotalcash}
(* ? *)
]
]

Testing

(*Returns:{{newPlayer1hand,bet,"H-(means more action is required on this hand) or S-(means this is the last action on the hand)"},newdeck,newcount,newtotalcash}*)

count:=0;decksinshoe:=1;deck:=Shoe[decksinshoe];totalcash:=100;favorablecount:=0;
{Player1hand,deck,count}=Deal[2,deck,count,decksinshoe];Player1hand
{dealerhand,deck,count}=Deal[2,deck,count,decksinshoe];dealerhand

PlayerDecision[Player1hand,dealerhand,deck,count,decksinshoe,totalcash,favorablecount]

Table[FileName=ToString[StringForm["filename``.csv",n]];
(*Import*)FileName,{n,1,4}]