Poker-AI.org

Poker AI and Botting Discussion Forum
It is currently Mon Nov 13, 2023 1:38 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Code to create a deck
PostPosted: Fri Aug 22, 2014 6:44 pm 
Offline
New Member

Joined: Fri Jul 11, 2014 4:29 pm
Posts: 8
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
        }


Top
 Profile  
 
PostPosted: Wed Aug 27, 2014 2:57 pm 
Offline
New Member

Joined: Fri Feb 21, 2014 2:13 pm
Posts: 6
I use a BitArray to store the card information
If I'm not mistaken, I got (stole) the idea from Spears LUT handevaluator


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group