War Stepper:Original No additional cards played in a war!

The state for war is three piles of cards: P1, P2, W.  P1 is the ordered list of cards for player one, P2 is the same for player two. W is the pile for ties.

Description in words of the play.

WarStepper[{P1In_,P2In_,WIn_},0]:= Module[
{P1=P1In, P2=P2In,W=WIn,LastCard1,LastCard2,TempCards},
(*  *)
LastCard1=P1[[-1]];  P1=Drop[P1, -1];
LastCard2=P2[[-1]];  P2=Drop[P2, -1];
TempCards={LastCard1,LastCard2};
(* Anything *)
Which[
LastCard1>LastCard2, P1=Join[TempCards,W,P1];W={},
LastCard1<LastCard2, P2=Join[TempCards,W,P2];W={},
LastCard1==LastCard2, W=Join[TempCards,W]
];
{P1,P2,W}
]

WarStepper[{{},P2In_,WIn_} ,0]:= Module[
{},
(*Print["P1 Lost"];*)
{{},P2In,WIn}
]
WarStepper[{P1In_,{},WIn_},0 ]:= Module[
{},
(*Print["P2 Lost"];*)
{P1In,{},WIn}
]
WarStepper[{{},{},WIn_},0 ]:= Module[
{},
(*Print["Tie"];*)
{{},{},WIn}
]

testing

State= {{2,12,11}, {5,13,10,3, 11},{} } 
State=WarStepper[State,0]
State=WarStepper[State,0]

War Stepper:New More than one Card played in a war!

The state for war is three piles of cards: P1, P2, W.  P1 is the ordered list of cards for player one, P2 is the same for player two. W is the pile for ties.   n is the number of additional cards played during a war.

Description in words of the play.

WarStepper[{P1In_,P2In_,WIn_},n_]:= Module[
{P1=P1In, P2=P2In,W=WIn,LastCard1,LastCard2,TempCards,m},
(*  *)
LastCard1=P1[[-1]];  P1=Drop[P1, -1];
LastCard2=P2[[-1]];  P2=Drop[P2, -1];
TempCards={LastCard1,LastCard2};
(* Anything *)
Which[
LastCard1>LastCard2, P1=Join[TempCards,W,P1];W={},
LastCard1<LastCard2, P2=Join[TempCards,W,P2];W={}, 
LastCard1==LastCard2, 
	(* Explain *) 
	m=Min[{Length[P1],Length[P2]}]-1;
	(* Adding m cards from P1 and n cards from P2 *)
	TempCards=Join[TempCards,P1[[-m;;-1]]];P1=Drop[P1,-m];
	TempCards=Join[TempCards,P2[[-m;;-1]]];P2=Drop[P2,-m];
         (* Adding the temp cards to W*)
	W=Join[TempCards,W]
];
{P1,P2,W}
]

testing

State= {{2,12,11}, {5,13,10,3, 11},{} } 
State=WarStepper[State,1]
State=WarStepper[State,1]

State= {{2,12,11}, {5,13,10,3, 11},{} } 
State=WarStepper[State,3]

State=WarStepper[State,2]

Not Sure

State= {{}, {5,13,10,3, 11},{} } 
State=WarStepper[State]
State=WarStepper[State]

State= {{2,12,11,13}, {5,13,10,3, 11},{}};
Data=Transpose[
Table[
State=WarStepper[State];
Map[Length,State],
{50}]
];
ListPlot[ Data,
Joined->True,
Mesh->All,
Frame->True,
GridLines->Automatic,
(*PlotMarkers->{"1","2","☺"},*)
FrameLabel->{"step","# of cards"},
PlotStyle->{Red,Blue, Green}]

State= {{2,12,11,13}, {5,13,10,3, 11},{}};
Data=Map[Length, 
NestList[ WarStepper, State,50],
{2}]

WarTest[{P1_,P2_,W_}] := Not[And[ W=={}, Min[Map[Length,{P1,P2}]]==0]]
WarTest[{{},{1,23},{}}]
WarTest[{{1,2},{1,23},{}}]
WarTest[{{1,2},{1,23},{1,2}}]

State= {{2,12,11,13}, {5,13,10,3},{}};
MyMaxSteps= (10^4);
Data=Map[Length,
 NestWhileList[ WarStepper, State,WarTest,1,MyMaxSteps],
{2}]

ListPlot[ Data,
Joined->True,
Mesh->All,
Frame->True,
GridLines->Automatic,
(*PlotMarkers->{"1","2","☺"},*)
FrameLabel->{"step","# of cards"},
PlotStyle->{Red,Blue, Green}]

State= {{2,12,11,3,4}, {5,13,10,3, 11,13,11},{}};
Fred=Transpose[Table[
State=WarStepper[State];
Map[Length,State],
{500}]];
ListPlot[ Fred]

State
WarStepper[State]

Decks

SetDeck=Table[ 
{i,j,k,m},
{i,1,3},
{j,1,3},
{k,1,3},
{m,1,3}];
SetDeck= RandomSample[
Flatten[SetDeck,3]
]

Here we are testing if thrre cards form a set. This would work for more than 4 properties if we want to.

IsSet[ {c1_,c2_,c3_}]:= Module[
{},
Max[Mod[c1+c2+c3,3]]==0
]

testing

IsSet[{ 
{2,1,1,3},
{1,2,1,3},
{3,3,1,3}
}]

αβχδϵϕγηιφ
[[

SetState={SetDeck[[13;;81]],SetDeck[[1;;12]],{}};
PossibleSets=Subsets[SetState[[2]],{3}];

CheckSet=Map[IsSet, PossibleSets];
RandomChoice[Position[CheckSet,True]]

RandomChoice[{}]

Binomial[12,3]

Clear[TwentyOneDeck,n]
TwentyOneDeck[n_]:=RandomSample[ 
Flatten[Table[ 
i,
{i,1,13},
{4},
{n}]
]
]

TwentyOneDeck= Flatten[TwentyOneDeck[3]]

Other Stuff: Shopping list

Need to: 
1) Deal Some number of Cards.
2) Implement wiki 12 startegy table
3) Maintain 3 piles of cards for war and stes
4) Detect sets
5) Understand if/then and other similar things.