CardsMarkup
Questions answered by this recipe
- How can I easily display information about card games such as contract bridge?
Description
The cards.zipΔ recipe provides markups to make it easy to display playing card suits and players' hands in a variety of layout formats. For example, with this recipe one can easily write things such as:
6 2 K Q 9 4 Q 5 A 8 5 4 2 | ||
A Q J 10 3 8 7 3 J 10 2 Q 7 | 9 8 7 5 5 K 9 8 7 4 J 9 3 | |
K 4 A J 10 6 2 A 6 3 K 10 6 |
South | West | North | East |
1 | 1 | 2 | 2 |
Pass | Pass | 3 | Pass |
4 | All Pass |
Opening Lead: J
Displaying card suits
This recipe defines the markups " s ", " h ", " d ", and " c " as shortcut notations for card suits like spades ( ), hearts ( ), diamonds ( ), and clubs ( ). The spaces around each of s, h, d, and c are required. With this, one can easily create things such as:
Bid 1 h , the suit below the doubleton. If partner bids 2 c , your rebid is 2 d , permitting partner to return to 2 h cheaply. |
Bid 1 , the suit below the doubleton. If partner bids 2 , your rebid is 2 , permitting partner to return to 2 cheaply. |
Displaying a hand
Display of hands is performed using the (:cards:)
directive. Hands are specified by entering the cards of each suit separated by dots. The ten may be specified as either "T" or "10". To display an empty (void) suit, simply omit cards from that suit. Thus a specification of (:cards k487.ajt62..kt65:)
results in:
K 4 8 7 A J 10 6 2 K 10 6 5 |
To display several players' hands at once, simply combine the hands separated by spaces. By default the first hand given is "North", but a hand's position may be specified by prefixing it with one of "N:", "E:", "S:", or "W:". Subsequent hands are taken as being the next position clockwise from the previous position.
(:cards "W:.63.AKQ987.A9732 A8654.KQ5.T.QJT6 J973.J98742.3.K4 KQT2.AT.J6542.85" :) | |||||||||
|
To suppress the display of one or more of the hands, use a hyphen:
(:cards "W:.63.AKQ987.A9732 - J973.J98742.3.K4 -" :) | |||
|
Similarly, use a hyphen to suppress the display of a suit altogether (as opposed to simply showing an empty or void suit):
(:cards "W:-.63.-.- -.KQ5.-.- -.J98742.-.- -.AT.-.-" :) | |||||||||
|
Notes
- The notation used for representing cards is based on Portable Bridge Notation (PBN).
Homepage of PBN
Release Notes
See Also
- Cookbook.ChessMarkup - Display chessboards in arbitrary positions
Contributors
Sandbox
Feel free to experiment with the card markups below.
Comments
See discussion at CardsMarkup-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.