Previously, in the company's project development, I was responsible for solving such a problem: in the landlord game, analyze this hand style according to the player's card.
Everyone knows that in the landlord game, there is a total of eleven types:
Rocket: 即 Double king (king and Xiao Wang). Bomb: Four Simplified Cards (such as four 7). Single card: single card (such as Porcea 5). Both cards (such as plum blossom 4 square 4). Three cards: three cards (such as three J). Three bands one: a value of the same value a single or a pair of cards. For example: 333 6 or 444 99 single smooth: Five or more consecutive single cards (such as: 45678 or 78910 Jqk). Does not include 2 points and double king. Double Shun: Three or more Continuous counterparts (such as: 334455, 7788991010jj). Does not include 2 points and double king. Sanshun: Two or more consecutive three consecutive cards (eg: 333444, 555666777888). Does not include 2 points and double king. Airplane with wings: three sho same number of single cards (or the same number of on the card). Such as: 444555 79 or 33344555 7799JJ four band two: four cards two-handed cards. (Note: The four bib is not a bomb). Such as: 5555 3 8 or 4444 55 77.
So, how to analyze this handbook is a brand of brand?
Before we try to solve this problem, let's take a look at how to distinguish between a realistic life. In the landlord game, an important basis for determining different brand types is to see how many cards in this hand is the same. For example, a card like a hand: Plum 2 square 3 red peach 3 black peach 3, in our thinking, first calculate the number of those cards with the same number, that is, three 3, here, 3 total 3 times appeared. According to the case of the same number, we can divide a hand into four situations:
1. All numbers only appear once
2, the same number of cards appear twice
3, three times of the same number
4, four times of the same number
5, it is impossible to appear: The same number of the same number is greater than four or less than once.
Among them, in the above 1, 2, 3, 4 may be divided into a variety of situations, such as in 1, although the same number is only once, but it is not possible to conclude it is single, it may also be a double king. (This assumes that the numbers of the size are different) or smooth; in the case of 2, it is further divided into: pairs of children and doubles; in 3, there may be three times, may Have the following brand: single three, three bands one, three shots or planes; 4 identical digital cards, there may be the following brand: bomb and four bibs.
In order to establish such an analytical model, we need to sort and statistically, find the maximum number of identities and the same number, and then analyze its characteristics until the current card is finalized. Used to implement a brand type analysis pseudo process is as follows:
Note: Cardlist is the list of cards, CardCount is the number of passes. Two-dimensional array CardArray [0..12, 0..1] is a auxiliary data structure for analysis. 1. Sort by order to CardList's digital size
2, the following operations for each card in Carlist
The number of cardList is recorded in the low dimension of CardArray. After the successor, if it is determined whether the repayment is equal to the CardArray [x, 0] value of the CardArray's current location, if equals, add 1 in Card [x, 1], to find the number of the same card, if not, if not, The new unit CardArray [x 1,0] is recorded in the number of CardList's current card, and sets CardArray [x 1, 1] to 1. So loop, after scanning each card in the cardList, the low-dimensional store is all the numbers that appear in the current hand, and the number of times these numbers appear in the corresponding high dimension. From this two-dimensional array, we can initially determine the brand of this hand.
This is the brand type analysis method I use in actual work. This method was originally proposed by our Teamleader. Later I made some small changes, I don't know if there is a friend who has studied the same problem. If there is a better way to judge Please enlighten me.