I have 52 PNG files on my machine, one for each playing card in a standard deck. I'm trying to make a poster to display all 3744 possible full house hands in a game of poker, arranged in a grid like 78 rows by 48 columns (or whatever looks good for the wall space I have). The PNG files themselves are small, no more than 40KB, but there are going to be more than 18000 of them in the finished file. Still, this should be possible, right? :-)
Heh. This is breaking my machine, and I'm not sure why. I have a deck object and a cards Association[] that points each object in deck to a file on my machine.
deck = Flatten[
Table[
{rank, suit},
{rank, Join[Range[2, 10], {j, q, k, a}]},
{suit, {\[SpadeSuit], \[HeartSuit], \[DiamondSuit], \[ClubSuit]}}
],
1
]
cards =
Association[
Flatten @ Table[
{
Flatten[Append[Range[10], {j, q, k, a}]][[n]],
{ \[ClubSuit], \[DiamondSuit], \[HeartSuit], \[SpadeSuit]}[[
b]]
} ->
Magnify[Import[
StringReplace[
"theCorrectPath/number_suit.png",
{
"number" -> ToString[n],
"suit" -> ToString[b]
}
]
], .75], {n, 2, 14}, {b, 4}
]
];
I also have a fullHouseQ[] function, so I have a fullHouses variable as well as a cardsToHand[] function and a fullHouseHands variable; the last of these contains a list of 5 PNG figures from my machine.
fullHouses =
Select[
Subsets[deck, {5}],
fullHouseQ[#] &
];
cardsToHand[hand_] := Row[Map[cards[#] &, hand]]
fullHouseHands = cardsToHand /@ fullHouses;
For example, cardsToHand[fullHouses[[616]]]
generates this output. I can save this single hand as a 100KB PDF or as a 25KB PNG image file.
However, if I try to combine Export[], Partition[], and TableForm[], things go awry.
Export[
"pathname", (* this is correct for my machine :-) and it works at small grid sizes *)
TableForm[
Partition[
fullHouseHands,
48
],
TableSpacing -> {2, 2}
]
]
The computer works and works and works, and eventually returns something like this:
I'm not sure why, but if I don't try to Partition[] and TableForm[] the output, I am able to generate a list of 3744 5-card hands, and I can even export them into a PDF. The file, however, is ~250MB big, though I suppose that'll happen even in the version I want. There are also extra curly braces and commas that I don't want in the finished version.
Anyone have any thoughts on this? I appreciate any direction you can offer.