Skip to content

Commit 1786084

Browse files
Merge branch 'release/v1.8.1'
2 parents 21012b0 + a56c7f5 commit 1786084

10 files changed

+570
-566
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
### Change Log
22

3+
#### 1.8.1
4+
5+
* Simplify flush rank key and look-up.
6+
* Accept smaller non-flush rank offset table.
7+
* Observed performance gains of about 6%.
8+
39
#### 1.8
410

511
* Index cards by bytes.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ project(${PROJECT_NAME})
66
# Versioning.
77
set(SK_POKER_EVAL_VERSION_MAJOR 1)
88
set(SK_POKER_EVAL_VERSION_MINOR 8)
9-
set(SK_POKER_EVAL_VERSION_PATCH 0)
9+
set(SK_POKER_EVAL_VERSION_PATCH 1)
1010

1111
# Get the current commit.
1212
execute_process(

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ The extraordinarily lucky aspect of this is that the maximum non-flush key we ha
3535

3636
Taking v1.1 as the base line, the sampled relative throughput of random [SevenEval](https://github.com/kennethshackleton/SKPokerEval/blob/develop/src/SevenEval.h) access has been seen to have changed as follows (a higher multiple is better).
3737

38-
| Version | Relative throughput | Reason                            |
39-
| ------- | ------------------: | :-------------------------------- |
40-
| [1.1](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.1)   |               1.00 |                                   |
41-
| [1.4.2](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.4.2) |               1.18 | Hashing.                          |
42-
| [1.6](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.6)     |               1.50 | Remove branching from flush case. |
43-
| [1.7](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.7)     |               1.53 | Reduce the hash table.            |
44-
| [1.7.1](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.7.1) |               1.57 | Reduce the rank hash table.      |
45-
| [1.8](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.8) |               1.93 | Index cards by bytes.      |
38+
| Version | Relative throughput | Reason                             |
39+
| ----------------------------------------------------------------------------- | ------------------: | :---------------------------------------- |
40+
| [1.1](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.1)   |               1.00 |                                   |
41+
| [1.4.2](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.4.2) |               1.18 | Hashing.                          |
42+
| [1.6](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.6)     |               1.50 | Remove branching from flush case. |
43+
| [1.7](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.7)     |               1.53 | Reduce the hash table.            |
44+
| [1.7.1](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.7.1) |               1.57 | Reduce the rank hash table.      |
45+
| [1.8](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.8) |               1.93 | Index cards by bytes.       |
46+
| [1.8.1](https://github.com/kennethshackleton/SKPokerEval/releases/tag/v1.8.1) |               2.04 | Simplify flush key. Smaller offset table. |
4647

4748
## I want to contribute, how might I profile my change?
4849

src/Constants.h

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,18 @@
5151
#define ACE_FIVE 79415
5252

5353
#define TWO_FLUSH 1
54-
#define THREE_FLUSH 2
55-
#define FOUR_FLUSH 4
56-
#define FIVE_FLUSH 8
57-
#define SIX_FLUSH 16
58-
#define SEVEN_FLUSH 32
59-
#define EIGHT_FLUSH 64
60-
#define NINE_FLUSH (EIGHT_FLUSH+SEVEN_FLUSH+SIX_FLUSH+FIVE_FLUSH+FOUR_FLUSH+\
61-
THREE_FLUSH+TWO_FLUSH+1)
62-
#define TEN_FLUSH (NINE_FLUSH+EIGHT_FLUSH+SEVEN_FLUSH+SIX_FLUSH+FIVE_FLUSH+\
63-
FOUR_FLUSH+THREE_FLUSH+1)
64-
#define JACK_FLUSH (TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH+SEVEN_FLUSH+SIX_FLUSH+\
65-
FIVE_FLUSH+FOUR_FLUSH+1)
66-
#define QUEEN_FLUSH (JACK_FLUSH+TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH+SEVEN_FLUSH+\
67-
SIX_FLUSH+FIVE_FLUSH+1)
68-
#define KING_FLUSH (QUEEN_FLUSH+JACK_FLUSH+TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH+\
69-
SEVEN_FLUSH+SIX_FLUSH+1)
70-
#define ACE_FLUSH (KING_FLUSH+QUEEN_FLUSH+JACK_FLUSH+TEN_FLUSH+NINE_FLUSH+\
71-
EIGHT_FLUSH+SEVEN_FLUSH+1)
54+
#define THREE_FLUSH TWO_FLUSH<<1
55+
#define FOUR_FLUSH THREE_FLUSH<<1
56+
#define FIVE_FLUSH FOUR_FLUSH<<1
57+
#define SIX_FLUSH FIVE_FLUSH<<1
58+
#define SEVEN_FLUSH SIX_FLUSH<<1
59+
#define EIGHT_FLUSH SEVEN_FLUSH<<1
60+
#define NINE_FLUSH EIGHT_FLUSH<<1
61+
#define TEN_FLUSH NINE_FLUSH<<1
62+
#define JACK_FLUSH TEN_FLUSH<<1
63+
#define QUEEN_FLUSH JACK_FLUSH<<1
64+
#define KING_FLUSH QUEEN_FLUSH<<1
65+
#define ACE_FLUSH KING_FLUSH<<1
7266

7367
// _SEVEN tag suppressed
7468
#define TWO 0
@@ -87,10 +81,10 @@
8781
// end of _SEVEN tag suppressed
8882

8983
#define MAX_FIVE_NONFLUSH_KEY_INT ((4*ACE_FIVE)+KING_FIVE)
90-
#define MAX_FIVE_FLUSH_KEY_INT (ACE_FLUSH+KING_FLUSH+QUEEN_FLUSH+JACK_FLUSH+\
84+
#define MAX_FIVE_FLUSH_KEY_INT (ACE_FLUSH|KING_FLUSH|QUEEN_FLUSH|JACK_FLUSH|\
9185
TEN_FLUSH)
92-
#define MAX_SEVEN_FLUSH_KEY_INT (ACE_FLUSH+KING_FLUSH+QUEEN_FLUSH+JACK_FLUSH+\
93-
TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH)
86+
#define MAX_SEVEN_FLUSH_KEY_INT (ACE_FLUSH|KING_FLUSH|QUEEN_FLUSH|JACK_FLUSH|\
87+
TEN_FLUSH|NINE_FLUSH|EIGHT_FLUSH)
9488

9589
#define RANK_OFFSET_SHIFT 7
9690
#define RANK_HASH_MOD 127

src/FiveEval.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ mFlushRankPtr(new short unsigned[MAX_FIVE_FLUSH_KEY_INT+1]) {
9797
for (int l = 1; l < k ; ++l) {
9898
for (int m = 0; m < l; ++m) {
9999
if (!(i-m == 4 || (i == 12 && j == 3))) {
100-
mFlushRankPtr[face_flush[i] + face_flush[j] + face_flush[k] +
101-
face_flush[l] + face_flush[m]] = n++;
100+
mFlushRankPtr[face_flush[i] | face_flush[j] | face_flush[k] |
101+
face_flush[l] | face_flush[m]] = n++;
102102
}
103103
}
104104
}
@@ -125,13 +125,13 @@ mFlushRankPtr(new short unsigned[MAX_FIVE_FLUSH_KEY_INT+1]) {
125125
}
126126

127127
// Low straight flush.
128-
mFlushRankPtr[face_flush[0] + face_flush[1] + face_flush[2] +
129-
face_flush[3] + face_flush[12]] = n++;
128+
mFlushRankPtr[face_flush[0] | face_flush[1] | face_flush[2] |
129+
face_flush[3] | face_flush[12]] = n++;
130130

131131
// Usual straight flush.
132132
for (int i = 0; i < 9; ++i) {
133-
mFlushRankPtr[face_flush[i] + face_flush[i+1] + face_flush[i+2] +
134-
face_flush[i+3] + face_flush[i+4]] = n++;
133+
mFlushRankPtr[face_flush[i] | face_flush[i+1] | face_flush[i+2] |
134+
face_flush[i+3] | face_flush[i+4]] = n++;
135135
}
136136
}
137137

@@ -147,10 +147,10 @@ short unsigned FiveEval::GetRank(int const card_one, int const card_two,
147147
(mDeckcardsSuit[card_one] == mDeckcardsSuit[card_three]) &&
148148
(mDeckcardsSuit[card_one] == mDeckcardsSuit[card_four]) &&
149149
(mDeckcardsSuit[card_one] == mDeckcardsSuit[card_five])) {
150-
return mFlushRankPtr[mDeckcardsFlush[card_one] +
151-
mDeckcardsFlush[card_two] +
152-
mDeckcardsFlush[card_three] +
153-
mDeckcardsFlush[card_four] +
150+
return mFlushRankPtr[mDeckcardsFlush[card_one] |
151+
mDeckcardsFlush[card_two] |
152+
mDeckcardsFlush[card_three] |
153+
mDeckcardsFlush[card_four] |
154154
mDeckcardsFlush[card_five]];
155155
}
156156
return mRankPtr[mDeckcardsFace[card_one] +

0 commit comments

Comments
 (0)