About Texas hold'em game Algorithms

Source: Internet
Author: User

About Texas hold'em game Algorithms

By wojishi3344
QQ: 513670524

Emal: phchengxu@163.com

I rely on it. The summer in Chongqing is really not a human experience. Before the beginning of June, the temperature has reached 36 °. People like me, just stay at home, drink a bottle of wine and write code. Today, I will share with you that the Texas Game poker game algorithm has also contributed to my chess and card game column. This blog post is suitable for cainiao programmers like me. You can go and blow air conditioners and bubble girls. If you cannot see it, please remember to introduce it to your brother !!!

 

Texas hold'em poker, short for Texas hold'em poker. It originated in the early 20th century and began in the town of loubus, Texas. It is said that the local people invented a poker game that can be attended by many people at the same time, So Texas hold'em was born. It is a public card game for players. There should be at least 2 persons on a table, and a maximum of 22 persons, usually 2-10 persons. Texas hold'em has 52 cards without trump cards. Each player is divided into two cards as the "base card", and five public cards are gradually issued by the dealer. At the beginning, each player will have two cards facing down. After all the bet circles, if the game still cannot win, the game will enter the "showdown" stage, that is, to let all the remaining players shine their respective cards to compete, the winner of the big card.

-------------------------- <From Baidu encyclopedia>

Texas hold'em is a very skillful poker game with a certain amount of luck, but players mainly rely on fighting intelligence, playing their wrists, and using their brains. Its rules are simple and easy to master, but it is difficult to be proficient.

 

We can define an enumeration to list all the card types:

// Card type enumeration Enum cardtypeenum {ctnonecard = 0, cthighcard, // high-card ctdouble_onecard, // a pair of ctdouble_twocard, // two pairs of ctthreecard, // three ctstraightcard, // ctflushcard, // ctgourdcard of the same flower, // ctfourcard of the three plus pairs (gourd), // four ctstraightflush, // ctroyalflush of the same flower, // ctroyalflush of the same flower };

The card type is small to large.

 

Texas hold'em game has a total of 52 cards. We can first define an array to save 52 card int narraycard [52] and store them in sequence 0------51, next we need to disrupt the array order to achieve the random licensing effect, and then issue two cards in turn. The specific explanation is written here. You can refer to my previous Algorithm for shuffling and licensing landlords. Http://blog.csdn.net/wojiushi3344/article/details/7522245.

 

If you already understand the shuffling and licensing algorithm. Congratulations, you can continue reading it.

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

 

You can define a struct to store the information data of each card for further discussion.

 

// Card information struct cardstruct {int s_ncardindex; // card index value 0-51int s_ncardvalue; // card size s_s_ncardsuit; // card color (1 black peach, 2 red peach, 3 plum blossom, 4 blocks) int s_nimage_x; // X coordinate int s_nimage_y of the card in the large image; // y coordinate in the large image };

Each player's card may be combined into any card type listed above. We all know the truth. If a silk has been in love with a sister paper for a long time, you can chat with your sister-in-law, press the road together, hold hands together, kiss your mouth, and go to bed. You will choose that. I think you will choose the last one if there are no problems in that aspect !. In the same sense, you can combine a deck of cards into the largest card type, so why do you need to combine them into the smallest card type. In this way, we will come up with the idea of making a comparison card model. First, we will find the largest card model. If the biggest one doesn't work, we will find the second one.

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.