Standard deck of 52 playing cards in curated data?

You can get some nice vector playing cards from this site, licensed under GNU LGPL (read more here). Download this folder to your computer and then try the following:

(* replace with your download dir *)
files = Flatten@With[{dir = "~/Downloads/Chrome/mma/SVG_and_EPS_Vector_Playing_Cards_Version_1.3/EPS_Vector_Playing_Cards_Version_1.3/52-Individual-Vector-Playing-Cards-1.2_(EPS-Format)/"},
    FileNames["*.eps", dir, 2]];

Clear@CardData
SetAttributes[CardData, Listable]
StringCases[Last@FileNameSplit@#, card__ ~~ ".eps" :> 
    (CardData[card] = ImageCrop@Import@#)] & /@ files;

You can then use this like any other curated data:

GraphicsRow[CardData@{"2C", "KH", "AS", "QD", "JC"}]


Random hand generator:

You can extend this further and also create a random hand generator using Mathematica as follows:

deck = Flatten@With[
    {
        ranks = CharacterRange["2", "9"] ~Join~ {"10", "J", "Q", "K", "A"}, 
        suits = {"C", "S", "H", "D"}
    },
    Outer[StringJoin, ranks, suits]
];
dealHand[n_Integer] /; 1 ≤ n ≤ 52 := CardData@RandomSample[deck, n]

Use this to deal a hand as dealHand[5], for instance. You'll have to modify this a bit to deal randomly and exhaust the deck at the same time (as you would in a game). There was a question on this previously on this site and I gave an answer based on Internal`Bag[] that will be useful here (along with some of the other answers there).


Not super high quality, but this might do for some purposes:

cards = Join[
  Table[ToString[k], {k, 2, 10}],
  {"Jack", "Queen", "King", "Ace"}];
suits = {"hearts", "diamonds", "clubs", "spades"};
deck = Flatten[Outer[#2 <> " of " <> #1 &, suits, cards]];
images = Table[
  WolframAlpha[card, {{"Image", 1}, "Content"}], {card, deck}];
Grid[Partition[images, 13]]

enter image description here

In terms of your real question, namely "how to find out what all is included as curated data", I had no clue if playing card images were included or not. I simply asked Wolfram Alpha via a query like so:

enter image description here

Choosing "Subpod content" as shown, I learned that the command to access the image is

WolframAlpha["4 of clubs", {{"Image", 1}, "Content"}]

I couldn't figure out how to access the whole deck at once, but from here I was able to put the whole thing together programmatically.


It is not entirely clear to me whether the playing cards in your question are just an example of what you want to find or the actual target. Since the other answers already provide you with the latter I'll provide a way to explore ExampleData.

The following two lines of code will build a complete overview of what's hidden in there. Running it may take a bit of time as most of the data will have to be transfered from the Wolfram server to your local paclet store for the first time.

switchedDisplay[stuff_] :=  
   DynamicModule[{x=False}, 
       Row[{"Show:  ", Checkbox[Dynamic[x]], "    ", 
             Dynamic[If[x, ExampleData@stuff, stuff], SynchronousUpdating -> False]}]
   ]
TabView[# -> TabView[switchedDisplay /@ ExampleData[#]] & /@ ExampleData[]]

Mathematica graphics Mathematica graphics Mathematica graphics Mathematica graphics

MacOS

MacOs doesn't seem to like long TabViews, so the code may have to be changed a little bit.

This adds another layer of TabViews where necessary:

MacMax = 30;
TabView[# -> 
    TabView[If[Length@ExampleData[#] > MacMax, 
      TabView /@ Partition[switchedDisplay /@ ExampleData[#], MacMax],
       switchedDisplay /@ ExampleData[#]]] & /@ ExampleData[]]

MacOS user MarkMcClure reports that ControlPlacement -> {Top, Left} in TabView also prevents problems from occurring.

Tags:

Curated Data