Chess Platform Construction Tutorial-Texas Hold ' em algorithm detailed

Source: Internet
Author: User

Texas hold ' em is a very powerful poker game, there is a certain amount of luck, but the players are mainly to rely on fighting intelligence, play wrist, brains. Its rules are very simple, relatively easy to grasp, but to achieve mastery of the realm has a certain degree of difficulty.

We can define an enumeration to list all the cards:

[CPP] view plain copy

  1. //Type enumeration of Cards   

  2. enum Cardtypeenum

  3. {

  4. Ctnonecard = 0,

  5. Cthighcard, //High card

  6. Ctdouble_onecard,//pair

  7. Ctdouble_twocard,//Two pair

  8. Ctthreecard, //three strips

  9. Ctstraightcard, //Shun son

  10. Ctflushcard, //With flowers

  11. Ctgourdcard, //three plus pair (gourd)

  12. Ctfourcard, //Four strips

  13. Ctstraightflush, //flush

  14. Ctroyalflush //Royal Flush

  15. };


Card size from small to large.

Texas hold ' em game a total of 52 cards, we can first define an array to save 52 cards int narraycard[52] inside and then save 0------51, then we need to scramble the order of the array to achieve the effect of random licensing, and then send 2 cards in the hands of the players in turn. The specific explanation in this is written, we can refer to the chess platform to make http://www.yasewl.com

If you have now understood the shuffle, the licensing algorithm. Well, congratulations, you can keep looking down.

Next, we start to discuss how to determine the player's hand in the hands of the card type.

You can define a struct to hold the information data for each card so that we will discuss it in the next step.

[CPP] view plain copy

  1. //Card information   

  2. struct cardstruct

  3. {

  4.      int  s_ncardindex;       //card 0-51   

  5.      int  s_ncardvalue;       //card 2345678910111213

  6.      int  s_ncardsuit ;       //(1 Spades, 2 hearts, 3 plum, 4 blocks)

  7.      int  s_nimage_x;         //card in the large picture   

  8. int       s_nimage_y; //y-coordinate in large picture

  9. };



This article is from the "Chess Card source Building Tutorial" blog, please be sure to keep this source http://13114207.blog.51cto.com/13104207/1945951

Chess Platform Construction Tutorial-Texas Hold ' em algorithm detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.