texas_algorithm 1.0.12 released, Texas Hold'em algorithm

Texas Hold'em Algorithm

Texas Hold'em algorithm is used with a ghost cards currently support two ghosts, including the following features

  • Look-up table algorithm (memory footprint than a dozen M)
  • Evaluation algorithm (memory footprint 300M)

 

use

<dependency>
    <groupId>com.github.esrrhs</groupId>
    <artifactId>texas_algorithm</artifactId>
    <version>1.0.12</version>
</dependency>
// Get two hand five community cards maximum five cards 
TexasAlgorithmUtil.getMax ( "Black 2 Black 3", "side 2, side A, black 7, Black 5, ghost"); 
// Get 7 size cards, more than a license for 
int win = TexasAlgorithmUtil.getWinPosition ( "side 4, side a, ghost, black a, black 3, 5 black, black 6"); 
// get the two hand four community cards winning for evaluating 
float p = TexasAlgorithmUtil.getHandProbability ( "side 3, ghost", "black 2 black 4, 5 black, black K");

 

Test play

  • Unzip texas_algorithm.rar to the current folder
  • Run TestUtil.Main

 

Make Table play

  • Unzip texas_algorithm.rar to the current folder
  • Run TexasAlgorithmUtil.Main, you need to add vm parameters -Xmx8000m

 

Lookups

Algorithm look-up table, a given one of seven cards (5 and 6 also support), look-up table gives the maximum five card poker face and size, winning percentage, type. Table lookup method is very simple, here to talk about the algorithm used to generate the table.

 

Algorithm

 

Exhaustive combination of C (52, 7) of

52 cards plus two ghost cards 7 which is selected from a total of 100 million in various combinations, of cards encoded into seven type long, to give an array of length 100 million.

  • Given 6 and 5, it is the same token generated

 

Multithreaded quicksort

The length of this array 100 million were from small to large, the size of the sort is 7 election after five. The use of multi-threading quick sort, on the 8-core machine, drained takes about 10 hours.

  • If the ratio of the original card replacement algorithm final lookup table algorithm, the speed can be shortened to 2 hours.

 

The results output

The array is already sorted, now in the order of output to a file, the contents key, the order, the value card ma x, max card type, card reading surface information. Finally, the file size is almost 12G.

  • In fact, note that the size is stepped, there are many cards that are as large, but different order, so when output than to do what the card handling.

 

The results go color

100 million if the direct use of data, the memory will burst, the use of algorithms to reduce color scale. Color and no color divided into two files, the total size of the final document 18 M. Actually loaded into memory footprint tens M.

  • For the type of flush, such as flush, straight flush, royal flush, the distribution of 7 cards must be such as red and red plum black, is at least five cards are the same suit, so you can change colors become Fang Fang Fang Fang dark side, saving key value
  • For non-flower type, color has no effect, then just need to remove all color, become Fang Fang Fang Fang Fang Fang Fang to

 

Query methods

Given seven cards, go check the table with flowers, if not go to extraordinary flower table investigation, two have a general election on who's who.

 

Evaluation algorithm

Assessment algorithm, given two hands 0-4 Zhanggong card, a rough estimate of this winning hand in the case of 1v1.

 

Algorithm

 

Winning percentage calculation

As already noted generated in order of card 7, so now given cards N (2 <= N <= 6), just need to set seven card's traversal, N cards to see which contains 7 the winning card, do what the average is the average winning percentage. Incidentally, the largest winning percentage will give birth to a minimum winning percentage. 5 final output file size is 2G.

 

The results go color

The N-card winning duplicate the same table, using a similar method to remove the color is divided into two tables, queries to query the original table, did not go to the lookup table to remove the suit. By this method, six files can be reduced to 300 M. Actually loaded into memory almost 200 M.

 

The board inquiry

The community cards into the above calculation of the winning table, the query to obtain winning situation public license, that the other side with the community cards to make up seven cards average winning percentage recorded as P1, and the maximum and minimum winning percentage P1Max and P1Min.

 

The board queries hand

Take my hand and community cards together, winning into the above table, the query to obtain an average winning percentage P2. Note that this time P2 is not accurate, because the hand is reused. Here there is an error.

 

Estimated Wins

P1, P2 have got, according to the relation of P1 and P2 can be derived to make the difference between winning and with P1Max P1Min. Here it is assumed that a uniform distribution will also have errors.

 

Estimated error

If using the most primitive way exhaustive of all combinations, namely fixed and fixed public hand cards, exhaustive remaining community cards and the other hand, and calculate the winning percentage, currently two hands four community cards need to be calculated over 20 days End, and the amount of data has been exceeded. By comparing the actual winning percentage, less than 0.1 most of the error, such as the actual winning 0.5, 0.6 estimate.

Guess you like

Origin www.oschina.net/news/108899/texas-algorithm-1-0-12-released