Re: Designing a Card Game



Peter Duniho wrote:
If I had a game where the card ordering was substantially different from the natural ordering the enumeration presents, I would use a look-up table. But I can't think of any card game where that's true (not that they don't necessarily exist...I'm just not familiar with them). I definitely wouldn't use that as a general-purpose strategy. I think that inheriting the ordering the enumeration provides is a perfectly fine approach in all of the cases I can think of.

Just about every card game has variations on the card ordering. The OP showed ACE as low card, whereas Bridge and most Poker variations rank it at the top.

We actually discussed this earlier in the thread. Mentioned were Canasta, Baccarat, Omaha Hi/Low and Crazy Eights, all quite popular. Klondike Solitaire treats Ace as the low card, and that may be the most commonly played card game ever. Rummy can play the Ace high or low. Even Bridge and many other games that treat Ace as high only do so relative to their own suit, and are higher than other non-trump cards that don't follow suit and lower than all trump cards if not trump themselves, and trump changes from hand to hand.

I can hardly think of two card games that rank cards the same way.

I don't think any card ordering qualifying as a "natural" ordering. There are just too many variations that no one ordering will ever cover but the smallest number of games of interest.

I can see defining a few standard Comparators, but most would need to be inner classes of Game so they can read Game state and apply appropriate logic, such as identification of the current trump card.

Card ranking is strictly a function of game rules, and is not inherent in the card at all, therefore should not be modeled as part of the Card class at all.

Hey, but if one wants to do it differently, have fun with the epicycles.

--
Lew
.