Poker-AI.org http://poker-ai.org/phpbb/ |
|
Code to create a deck http://poker-ai.org/phpbb/viewtopic.php?f=22&t=2796 |
Page 1 of 1 |
Author: | Watts [ Fri Aug 22, 2014 6:44 pm ] |
Post subject: | Code to create a deck |
Creating a deck of cards is a fun beginners problem, and I'm interested in seeing creative ways others have done it. Here's my stab at it in C#: Code: private List<KeyValuePair<Suits, byte>> createDeck()
{ List<KeyValuePair<Suits, byte>> deck = new List<KeyValuePair<Suits, byte>>(); for (byte i = 0; i < 52; i++) { Suits suit = i % 2 == 0 ? i % 4 == 0 ? Suits.Diamond : Suits.Heart : i % 4 == 1 ? Suits.Spade : Suits.Club; deck.Add(new KeyValuePair<Suits, byte>(suit, (byte)(i % 13))); } return deck; } public enum Suits { Club, Diamond, Heart, Spade } |
Author: | Bliss [ Wed Aug 27, 2014 2:57 pm ] |
Post subject: | Re: Code to create a deck |
I use a BitArray to store the card information If I'm not mistaken, I got (stole) the idea from Spears LUT handevaluator |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |