poker card game revisited (code included)
Erik Max Francis
max at alcyone.com
Thu Jun 9 00:43:04 EDT 2005
John Hazen wrote:
> Interesting. I've been thinking about playing with this stuff too, but
> hadn't considered masks. So each card has a representation:
>
> n bits for rank, then m bits for suit.
>
> 00000000000010 0001 = 2 clubs
> 01000000000000 1000 = K spades
> ...
You can also deal with them as a mask of card indexes. So the deuce of
clubs is bit 0, the three of clubs is bit 1, all the way up to the ace
of spades, which is bit 51. (That obviously won't fit in an int; you'll
need a long.)
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
You are the lovers rock / The rock that I cling to
-- Sade
More information about the Python-list
mailing list