View Single Post
  #4  
Old 11-15-2007, 05:51 PM
Subfallen Subfallen is offline
Senior Member
 
Join Date: Sep 2004
Location: Worshipping idols in B&W.
Posts: 3,398
Default Re: Programming a Poker Game

Enumerate suits as 0-3 and ranks as 0-12. Then represent each card as an integer, where:
- ID = suit * 13 + rank
Then for card 'c':
- suit of c = c / 13
- rank of c = c % 13

The deck can now be a one-dimensional array. If you order suits Clubs, Hearts, Spades, Diamonds (0-3), then 0 is the 2[img]/images/graemlins/club.gif[/img] and 51 is the A[img]/images/graemlins/diamond.gif[/img].
Reply With Quote