Skip to content

Commit

Permalink
Merge branch 'release/1.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethshackleton committed Oct 24, 2016
2 parents 1be6b01 + 2f11e7b commit 28e7d26
Show file tree
Hide file tree
Showing 9 changed files with 9,357 additions and 54 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
### Change Log

#### 1.4.2

* CHM perfect hash of seven rank keys, optimisation that also reduces footprint.

#### 1.4.1

* Minor optimisation when ranking flushes.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -6,7 +6,7 @@ project(${PROJECT_NAME})
# Versioning.
set(SK_POKER_EVAL_VERSION_MAJOR 1)
set(SK_POKER_EVAL_VERSION_MINOR 4)
set(SK_POKER_EVAL_VERSION_PATCH 1)
set(SK_POKER_EVAL_VERSION_PATCH 2)

# Get the current commit.
execute_process(
Expand Down
7 changes: 4 additions & 3 deletions src/Constants.h
Expand Up @@ -86,16 +86,17 @@
#define MAX_SEVEN_FLUSH_KEY_INT (ACE_FLUSH+KING_FLUSH+QUEEN_FLUSH+JACK_FLUSH+\
TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH)

#define MAX_FLUSH_CHECK_SUM (7*CLUB)
#define RANK_OFFSET_SHIFT 12
#define RANK_HASH_MOD 4095

#define CIRCUMFERENCE_SEVEN 4565145
#define MAX_FLUSH_CHECK_SUM (7*CLUB)

// Used in flush checking. These must be distinct from each of the suits.
#define UNVERIFIED -1
#define NOT_A_FLUSH -2

// Bit masks
#define SUIT_BIT_MASK 511
#define NON_FLUSH_BIT_SHIFT 9
#define SUIT_BIT_MASK (1<<NON_FLUSH_BIT_SHIFT)-1

#endif // SKPOKEREVAL_CONSTANTS_H_
13 changes: 6 additions & 7 deletions src/FiveEval.cpp
Expand Up @@ -3,10 +3,10 @@
FiveEval::FiveEval() :
mRankPtr(new short unsigned[MAX_FIVE_NONFLUSH_KEY_INT+1]),
mFlushRankPtr(new short unsigned[MAX_FIVE_FLUSH_KEY_INT+1]) {
int unsigned const face[13] = {TWO_FIVE, THREE_FIVE, FOUR_FIVE, FIVE_FIVE,
uint32_t const face[13] = {TWO_FIVE, THREE_FIVE, FOUR_FIVE, FIVE_FIVE,
SIX_FIVE, SEVEN_FIVE, EIGHT_FIVE, NINE_FIVE, TEN_FIVE, JACK_FIVE,
QUEEN_FIVE, KING_FIVE, ACE_FIVE};
int unsigned const face_flush[13] = {TWO_FLUSH, THREE_FLUSH, FOUR_FLUSH,
uint32_t const face_flush[13] = {TWO_FLUSH, THREE_FLUSH, FOUR_FLUSH,
FIVE_FLUSH, SIX_FLUSH, SEVEN_FLUSH, EIGHT_FLUSH, NINE_FLUSH, TEN_FLUSH,
JACK_FLUSH, QUEEN_FLUSH, KING_FLUSH, ACE_FLUSH};

Expand Down Expand Up @@ -160,15 +160,14 @@ short unsigned FiveEval::GetRank(int const card_one, int const card_two,
mDeckcardsFace[card_five]];
}

short unsigned FiveEval::GetRank(int const card_one, int const card_two,
int const card_three, int const card_four,
int const card_five, int const card_six,
int const card_seven) const {
uint16_t FiveEval::GetRank(int const card_one, int const card_two,
int const card_three, int const card_four, int const card_five,
int const card_six, int const card_seven) const {
int const seven_cards[7] = {card_one, card_two, card_three, card_four,
card_five, card_six, card_seven};
int temp[5];

short unsigned best_rank_so_far = 0, current_rank = 0;
uint16_t best_rank_so_far = 0, current_rank = 0;
int m = 0;

for (int i = 1; i < 7; ++i) {
Expand Down
15 changes: 8 additions & 7 deletions src/FiveEval.h
Expand Up @@ -21,6 +21,7 @@
#define SKPOKEREVAL_FIVEEVAL_H

#include "Constants.h"
#include <cstdint>

class FiveEval {
public:
Expand All @@ -29,17 +30,17 @@ class FiveEval {
// Get the rank of a hand comprising five cards, each represented by an
// integer from 0 (resp. Ace of Spades) to 51 (resp. Two of Clubs) inclusive.
// The higher the rank the better the hand. Two hands of equal rank tie.
short unsigned GetRank(int, int, int, int, int) const;
uint16_t GetRank(int, int, int, int, int) const;
// Get the rank of a hand comprising seven cards, each represented by an
// integer from 0 (resp. Ace of Spades) to 51 (resp. Two of Clubs) inclusive.
// The higher the rank the better the hand. Two hands of equal rank tie.
short unsigned GetRank(int, int, int, int, int, int, int) const;
uint16_t GetRank(int, int, int, int, int, int, int) const;
private:
short unsigned *mRankPtr;
short unsigned *mFlushRankPtr;
int unsigned mDeckcardsFace[DECK_SIZE];
short unsigned mDeckcardsFlush[DECK_SIZE];
short unsigned mDeckcardsSuit[DECK_SIZE];
uint16_t *mRankPtr;
uint16_t *mFlushRankPtr;
uint32_t mDeckcardsFace[DECK_SIZE];
uint16_t mDeckcardsFlush[DECK_SIZE];
uint16_t mDeckcardsSuit[DECK_SIZE];
};

#endif // SKPOKEREVAL_FIVEEVAL_H
9,186 changes: 9,186 additions & 0 deletions src/RankHash.h

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions src/RankOffsets.h
@@ -0,0 +1,142 @@
// SKPokerEval
//
// Copyright 2010 Kenneth J. Shackleton
//
// This program gives you software freedom; you can copy, convey, propagate,
// redistribute and/or modify this program under the terms of the GNU General
// Public License (GPL) as published by the Free Software Foundation (FSF),
// either version 3 of the License, or (at your option) any later version of
// the GPL published by the FSF.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program in a file in the top-level directory called "GPLv3". If
// not, see http://www.gnu.org/licenses/.

#ifndef SKPOKEREVAL_OFFSETS_H
#define SKPOKEREVAL_OFFSETS_H

#include <cstdint>

uint32_t const offsets[1911] = {
0, 4093, 7259, 10080, 11775, 13471, 17150, 19794, 23042, 18192, 5377, 25933,
27388, 28925, 2448, 2627, 8488, 23939, 1817, 299, 30947, 34930, 36757, 35699,
38150, 28907, 41481, 42561, 44420, 4189, 6011, 43493, 46317, 8842, 2406, 14, 61,
21699, 47, 1910, 27798, 47408, 18274, 48897, 827, 31567, 49670, 25101, 11589,
4643, 709, 1, 49509, 248, 2667, 0, 1, 394, 7, 10, 0, 50961, 3719, 25709, 54488,
57309, 59453, 58218, 60675, 62371, 65525, 66258, 67264, 10316, 11782, 69215,
34562, 47158, 1793, 1865, 7625, 67863, 5773, 10919, 70301, 72783, 72900, 75269,
21125, 8348, 76254, 4858, 63035, 37, 3969, 17735, 6278, 690, 75, 13, 0, 6328, 7,
32, 11767, 76923, 342, 39625, 202, 7881, 38352, 3985, 2940, 2, 23, 8, 8559, 1,
18, 0, 0, 7, 13, 1, 0, 51949, 3, 7469, 79147, 58391, 79916, 20163, 65233, 80666,
82346, 14401, 21762, 12, 171, 82695, 1309, 11085, 7, 14, 3465, 6215, 287, 88,
82326, 84710, 27593, 13940, 2778, 42, 84703, 85917, 89694, 91482, 94112, 83620,
94461, 96878, 66649, 100267, 16762, 89314, 93628, 99122, 75298, 97222, 5817,
16225, 100626, 432, 27380, 98487, 103171, 102185, 104660, 3239, 105385, 105919,
35010, 40267, 4911, 3062, 9689, 27646, 0, 44082, 2, 417, 107851, 14105, 107479,
155, 109914, 70396, 110230, 11654, 17419, 21877, 24597, 19717, 1168, 85, 484,
12658, 84, 1276, 1, 66, 18734, 16511, 8398, 80, 40281, 16536, 34606, 111719,
113934, 113708, 116020, 47617, 37210, 116611, 10069, 108868, 463, 17492, 23066,
19098, 5632, 33372, 6, 434, 19891, 21747, 46, 52491, 116487, 20778, 45309, 48,
28001, 56095, 5308, 7440, 1045, 4, 152, 5546, 0, 4184, 0, 0, 116731, 274, 22475,
21, 117151, 5805, 29490, 41, 121, 7363, 63, 192, 0, 0, 1, 20, 0, 1, 0, 0, 8379,
303, 27, 0, 11526, 433, 595, 118122, 45013, 47130, 31882, 12299, 524, 118570,
1074, 28374, 3, 117, 14649, 986, 10, 1128, 3, 0, 487, 1075, 0, 28292, 33739, 2,
29296, 0, 996, 22246, 119226, 122467, 120734, 123428, 24210, 47939, 124288,
45291, 72253, 5637, 15938, 30614, 34069, 325, 43323, 1, 4517, 25434, 34, 988, 6,
125862, 31396, 105610, 572, 34238, 48091, 39579, 8569, 501, 3, 2, 35380, 2,
3151, 8, 1, 61142, 38010, 15719, 1218, 50742, 37255, 55768, 1615, 2447, 2,
39100, 164, 2463, 1, 128517, 131338, 133033, 131670, 134861, 135674, 138915,
139640, 141075, 49887, 59761, 142588, 55091, 142942, 145622, 67836, 144848,
62154, 43876, 124698, 146654, 149787, 149528, 132618, 88514, 46845, 152059,
42624, 118230, 5521, 41161, 74251, 45299, 10614, 139238, 1870, 39282, 37505,
1401, 16590, 24950, 153323, 6438, 127902, 2387, 49206, 50432, 58199, 16380,
2928, 21191, 3636, 46169, 2, 23887, 3148, 3911, 72, 3, 0, 3080, 89083, 4529,
17681, 155268, 144785, 156490, 62676, 101847, 134332, 156174, 70862, 63773, 36,
43443, 146803, 7832, 78737, 50682, 3436, 11269, 27078, 5624, 38663, 156524,
159168, 99911, 51551, 20860, 3022, 140043, 4078, 50503, 5, 2506, 19817, 3441,
137, 37774, 3, 3466, 2965, 1, 557, 0, 160295, 61102, 160116, 3634, 60285,
118474, 63641, 33305, 3989, 68, 20, 63802, 66, 3626, 1, 3, 204, 0, 3, 9, 153087,
11631, 41313, 162228, 60430, 152404, 66053, 28468, 64097, 65729, 3552, 6993, 2,
4798, 50831, 5, 8527, 3691, 93, 682, 9155, 5245, 3412, 109277, 52805, 26070,
6438, 40, 38, 46346, 163348, 166257, 161730, 146804, 74557, 58231, 167183,
67437, 160685, 4808, 59307, 79273, 67407, 23297, 167526, 5695, 70145, 58289,
3987, 54093, 71261, 168354, 10621, 168704, 4922, 68429, 108162, 13356, 23104,
4719, 82, 3, 66340, 1, 63410, 5097, 416, 169439, 4482, 31778, 5656, 140729,
36625, 66573, 405, 1936, 3687, 8201, 3747, 5469, 176, 31, 3669, 0, 1503, 8, 1,
27777, 5091, 162, 2, 28019, 4669, 6425, 169007, 171298, 83191, 70204, 10995,
5076, 171699, 5965, 69934, 40, 4861, 30612, 5683, 1131, 71252, 4, 5540, 5251,
5965, 2544, 17969, 75902, 1, 72650, 0, 5906, 31511, 6780, 116, 3, 0, 0, 6162, 0,
3792, 0, 0, 72090, 1, 5330, 1, 170627, 11336, 44138, 7046, 2132, 783, 73612, 2,
6978, 0, 1, 2915, 5, 0, 1, 0, 1625, 2, 4, 0, 33622, 6268, 220, 86289, 73790,
34116, 7327, 1805, 1, 74050, 1, 6039, 2, 0, 2700, 0, 0, 6681, 0, 0, 1, 6782, 0,
0, 75473, 47, 7544, 0, 0, 3353, 111116, 172314, 17288, 77927, 6, 76981, 171059,
15221, 32986, 8100, 3112, 0, 77939, 0, 77457, 77, 3839, 3590, 8, 1, 8325,
172040, 7360, 76560, 0, 172, 16418, 7226, 38, 4, 0, 0, 6621, 0, 1213, 17, 0,
35818, 8475, 2828, 0, 40004, 8057, 8315, 2, 6, 0, 7927, 0, 0, 0, 174402, 173247,
176230, 79571, 90449, 147626, 177620, 57801, 94816, 77, 76718, 173157, 17755,
78561, 90542, 3672, 82715, 16512, 8505, 81311, 176701, 178070, 103430, 81430,
7779, 11185, 175451, 21516, 78842, 8, 4329, 17135, 7979, 721, 79241, 0, 7459,
7702, 1, 1217, 49, 179888, 9074, 82753, 16, 8070, 40455, 8779, 3118, 0, 3846, 0,
8412, 0, 3735, 3, 0, 2, 0, 0, 1, 41995, 9456, 3896, 179628, 87697, 179449,
13149, 44653, 75185, 88115, 34, 84391, 0, 9035, 60588, 16, 11239, 9992, 0, 9331,
9470, 61, 4748, 88922, 83227, 21728, 8232, 4, 170, 85974, 8, 8068, 0, 0, 9, 87,
0, 8350, 0, 0, 0, 0, 1, 0, 181107, 9164, 87108, 9, 8131, 47055, 9154, 1334, 73,
0, 37, 8493, 0, 0, 0, 0, 5, 0, 0, 0, 50009, 9630, 4000, 180047, 8629, 54472,
9441, 4649, 8408, 12195, 0, 10157, 0, 1, 5164, 28, 143, 96, 0, 13, 1, 10280, 2,
31232, 9381, 237, 92, 0, 38, 8955, 181079, 181872, 124352, 87969, 27292, 9132,
181806, 9951, 89016, 1, 8879, 47943, 9636, 9, 93025, 1, 9452, 9533, 9, 5516, 3,
183137, 10992, 90791, 0, 9920, 45032, 10726, 4356, 1, 7, 0, 10418, 0, 6879, 2,
0, 72052, 106, 5561, 79, 85728, 398, 6159, 0, 2, 0, 11168, 2, 3, 0, 3, 0, 0, 0,
2, 0, 5126, 1, 0, 0, 5121, 3, 0, 96511, 91923, 34552, 10291, 1426, 88, 91664,
53, 9877, 0, 0, 5493, 0, 4, 10191, 0, 2, 0, 1, 2, 0, 92468, 1, 10886, 0, 0,
6719, 9, 2, 0, 0, 0, 1, 0, 2, 0, 0, 9967, 0, 0, 0, 55898, 11733, 8130, 10, 1, 0,
11438, 0, 1, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 557, 151, 0, 49329, 11007, 6608,
6, 0, 0, 10837, 0, 1, 0, 0, 4, 0, 0, 1, 0, 0, 0, 1, 0, 0, 11509, 0, 0, 0, 0, 10,
16879, 96249, 55, 93759, 6, 11228, 47955, 11993, 7405, 1, 0, 0, 11688, 0, 7922,
0, 6, 0, 0, 0, 1, 88620, 201, 8051, 14, 2, 7, 188, 0, 1, 0, 0, 1, 0, 0, 33, 0,
7096, 1, 0, 0, 7396, 7, 2, 0, 0, 0, 1, 0, 0, 0, 183267, 94022, 118185, 94665,
49206, 50354, 94946, 105, 96077, 8, 11408, 56024, 12146, 8486, 95520, 129,
11758, 11872, 0, 9460, 96581, 99392, 10197, 12437, 0, 12179, 94403, 21, 9568,
52, 2, 1235, 43, 0, 10810, 0, 3, 0, 0, 0, 82, 96007, 20, 10925, 0, 0, 8564, 0,
0, 0, 0, 0, 1, 0, 5, 0, 0, 0, 0, 0, 0, 9432, 0, 1, 182781, 12505, 51793, 12259,
9490, 14, 97307, 73, 12164, 0, 7, 9870, 2, 17, 12655, 0, 1, 0, 2, 1, 30415,
11814, 416, 164, 0, 1, 11316, 0, 3, 0, 0, 0, 117, 0, 1, 0, 0, 0, 0, 0, 0, 96336,
0, 11340, 0, 0, 1924, 147, 0, 82, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9962, 0, 2,
56569, 213, 9927, 5, 1, 0, 12944, 0, 7, 0, 0, 3, 0, 0, 12, 0, 0, 0, 8, 0, 1565,
188, 0, 96, 0, 0, 0, 121939, 97838, 14876, 11963, 621, 181, 97586, 32, 11548, 0,
3, 1948, 243, 0, 11864, 0, 7, 1, 0, 1, 0, 98696, 15, 12188, 0, 0, 9469, 3, 0, 0,
0, 0, 0, 0, 0, 0, 0, 10950, 112, 0, 0, 11061, 5, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 168, 0, 37358, 12397, 1940, 263, 0, 83, 12088, 0, 2,
0, 0, 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, 12744, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 10892, 7, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 57, 0, 10071, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 99617, 0, 12890, 0, 0, 10741, 3, 3, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 11751, 163, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130721, 100211, 55848, 13454, 10849, 0, 102021, 1,
13190, 0, 8, 11324, 3, 0, 13514, 0, 0, 0, 0, 0, 11748, 14414, 0, 13940, 0, 3,
12343, 202, 5, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 13014, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57568, 14299, 11734, 0, 0, 0,
14013, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 637, 210, 0, 62, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12753, 0, 0, 0, 0, 0, 107, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 2, 0, 0, 12148, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 106, 0, 0, 0, 0, 0, 12687, 13365, 622, 206, 0, 46, 12872, 0, 2,
0, 0, 0, 152, 0, 5, 0, 0, 0, 0, 0, 0, 13580, 0, 2, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1976, 245, 0, 97, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13858, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

#endif
39 changes: 5 additions & 34 deletions src/SevenEval.cpp
@@ -1,8 +1,10 @@
#include "SevenEval.h"
#include "FiveEval.h"
#include "RankHash.h"
#include "RankOffsets.h"
#include <cstring>

SevenEval::SevenEval() : mRankPtr(new short unsigned[CIRCUMFERENCE_SEVEN]),
SevenEval::SevenEval() :
mFlushRankPtr(new short unsigned[MAX_SEVEN_FLUSH_KEY_INT+1]) {
int const face[13] = {ACE, KING, QUEEN, JACK, TEN, NINE, EIGHT, SEVEN, SIX,
FIVE, FOUR, THREE, TWO};
Expand Down Expand Up @@ -31,35 +33,6 @@ SevenEval::SevenEval() : mRankPtr(new short unsigned[CIRCUMFERENCE_SEVEN]),
// Generate seven-ranks from five-ranks.
FiveEval const eval;

// Non-flush ranks.
for (int i = 1; i < 13; ++i) {
int const I = i<<2;
for (int j = 1; j <= i; ++j) {
int const J = j<<2;
for (int k = 1; k <= j; ++k) {
int const K = k<<2;
for (int l = 0; l <= k; ++l) {
int const L = l<<2;
for (int m = 0; m <= l && m < i; ++m) {
int const M = (m<<2)+1;
for (int n = 0; n <= m && n < j; ++n) {
int const N = (n<<2)+1;
for (int p = 0; p <= n && p < k; ++p) {
int const P = (p<<2)+1;
int const key = face[i] + face[j] + face[k] + face[l] +
face[m] + face[n] + face[p];
// The (4*i)+0 and (4*m)+1 trick prevents flushes.
short unsigned const rank = eval.GetRank(I, J, K, L, M, N, P);
mRankPtr[key < CIRCUMFERENCE_SEVEN ?
key : key - CIRCUMFERENCE_SEVEN] = rank;
}
}
}
}
}
}
}

// Flush ranks, all seven of the same suit.
for (int i = 6; i < 13; ++i) {
int const I = i<<2;
Expand Down Expand Up @@ -181,7 +154,6 @@ SevenEval::SevenEval() : mRankPtr(new short unsigned[CIRCUMFERENCE_SEVEN]),
}

SevenEval::~SevenEval() {
delete[] mRankPtr;
delete[] mFlushRankPtr;
}

Expand All @@ -195,9 +167,8 @@ short unsigned SevenEval::GetRank(int const i, int const j, int const k,
if (flush_suit == NOT_A_FLUSH) {
// Tear off the non-flush key strip, and look up the rank.
key >>= NON_FLUSH_BIT_SHIFT;
// Take key modulo the circumference.
return mRankPtr[(key < CIRCUMFERENCE_SEVEN ? key :
key - CIRCUMFERENCE_SEVEN)];
return rank_hash[offsets[
key >> RANK_OFFSET_SHIFT] + (key & RANK_HASH_MOD)];
}
// Generate a flush key, and look up the rank.
int flush_key = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/SevenEval.h
Expand Up @@ -30,9 +30,8 @@ class SevenEval {
// Get the rank of a hand comprising seven cards, each represented by an
// integer from 0 (resp. Ace of Spades) to 51 (resp. Two of Clubs) inclusive.
// The higher the rank the better the hand. Two hands of equal rank tie.
short unsigned GetRank(int, int, int, int, int, int, int) const;
uint16_t GetRank(int i, int j, int k, int l, int m, int n, int p) const;
private:
uint16_t *mRankPtr;
uint16_t *mFlushRankPtr;
uint32_t mDeckcardsKey[DECK_SIZE];
uint16_t mDeckcardsFlush[DECK_SIZE];
Expand Down

0 comments on commit 28e7d26

Please sign in to comment.