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
//Type enumeration of Cards
enum Cardtypeenum
{
Ctnonecard = 0,
Cthighcard, //High card
Ctdouble_onecard,//pair
Ctdouble_twocard,//Two pair
Ctthreecard, //three strips
Ctstraightcard, //Shun son
Ctflushcard, //With flowers
Ctgourdcard, //three plus pair (gourd)
Ctfourcard, //Four strips
Ctstraightflush, //flush
Ctroyalflush //Royal Flush
};
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
//Card information
struct cardstruct
{
-
int s_ncardindex; //card 0-51
-
int s_ncardvalue; //card 2345678910111213
-
int s_ncardsuit ; //(1 Spades, 2 hearts, 3 plum, 4 blocks)
-
int s_nimage_x; //card in the large picture
int s_nimage_y; //y-coordinate in large picture
};
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