Skip to content

Commit

Permalink
Merge branch 'release/v1.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethshackleton committed Sep 24, 2017
2 parents 21012b0 + a56c7f5 commit 1786084
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 566 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
### Change Log

#### 1.8.1

* Simplify flush rank key and look-up.
* Accept smaller non-flush rank offset table.
* Observed performance gains of about 6%.

#### 1.8

* Index cards by bytes.
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 8)
set(SK_POKER_EVAL_VERSION_PATCH 0)
set(SK_POKER_EVAL_VERSION_PATCH 1)

# Get the current commit.
execute_process(
Expand Down
17 changes: 9 additions & 8 deletions README.md
Expand Up @@ -35,14 +35,15 @@ The extraordinarily lucky aspect of this is that the maximum non-flush key we ha

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).

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

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

Expand Down
36 changes: 15 additions & 21 deletions src/Constants.h
Expand Up @@ -51,24 +51,18 @@
#define ACE_FIVE 79415

#define TWO_FLUSH 1
#define THREE_FLUSH 2
#define FOUR_FLUSH 4
#define FIVE_FLUSH 8
#define SIX_FLUSH 16
#define SEVEN_FLUSH 32
#define EIGHT_FLUSH 64
#define NINE_FLUSH (EIGHT_FLUSH+SEVEN_FLUSH+SIX_FLUSH+FIVE_FLUSH+FOUR_FLUSH+\
THREE_FLUSH+TWO_FLUSH+1)
#define TEN_FLUSH (NINE_FLUSH+EIGHT_FLUSH+SEVEN_FLUSH+SIX_FLUSH+FIVE_FLUSH+\
FOUR_FLUSH+THREE_FLUSH+1)
#define JACK_FLUSH (TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH+SEVEN_FLUSH+SIX_FLUSH+\
FIVE_FLUSH+FOUR_FLUSH+1)
#define QUEEN_FLUSH (JACK_FLUSH+TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH+SEVEN_FLUSH+\
SIX_FLUSH+FIVE_FLUSH+1)
#define KING_FLUSH (QUEEN_FLUSH+JACK_FLUSH+TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH+\
SEVEN_FLUSH+SIX_FLUSH+1)
#define ACE_FLUSH (KING_FLUSH+QUEEN_FLUSH+JACK_FLUSH+TEN_FLUSH+NINE_FLUSH+\
EIGHT_FLUSH+SEVEN_FLUSH+1)
#define THREE_FLUSH TWO_FLUSH<<1
#define FOUR_FLUSH THREE_FLUSH<<1
#define FIVE_FLUSH FOUR_FLUSH<<1
#define SIX_FLUSH FIVE_FLUSH<<1
#define SEVEN_FLUSH SIX_FLUSH<<1
#define EIGHT_FLUSH SEVEN_FLUSH<<1
#define NINE_FLUSH EIGHT_FLUSH<<1
#define TEN_FLUSH NINE_FLUSH<<1
#define JACK_FLUSH TEN_FLUSH<<1
#define QUEEN_FLUSH JACK_FLUSH<<1
#define KING_FLUSH QUEEN_FLUSH<<1
#define ACE_FLUSH KING_FLUSH<<1

// _SEVEN tag suppressed
#define TWO 0
Expand All @@ -87,10 +81,10 @@
// end of _SEVEN tag suppressed

#define MAX_FIVE_NONFLUSH_KEY_INT ((4*ACE_FIVE)+KING_FIVE)
#define MAX_FIVE_FLUSH_KEY_INT (ACE_FLUSH+KING_FLUSH+QUEEN_FLUSH+JACK_FLUSH+\
#define MAX_FIVE_FLUSH_KEY_INT (ACE_FLUSH|KING_FLUSH|QUEEN_FLUSH|JACK_FLUSH|\
TEN_FLUSH)
#define MAX_SEVEN_FLUSH_KEY_INT (ACE_FLUSH+KING_FLUSH+QUEEN_FLUSH+JACK_FLUSH+\
TEN_FLUSH+NINE_FLUSH+EIGHT_FLUSH)
#define MAX_SEVEN_FLUSH_KEY_INT (ACE_FLUSH|KING_FLUSH|QUEEN_FLUSH|JACK_FLUSH|\
TEN_FLUSH|NINE_FLUSH|EIGHT_FLUSH)

#define RANK_OFFSET_SHIFT 7
#define RANK_HASH_MOD 127
Expand Down
20 changes: 10 additions & 10 deletions src/FiveEval.cpp
Expand Up @@ -97,8 +97,8 @@ mFlushRankPtr(new short unsigned[MAX_FIVE_FLUSH_KEY_INT+1]) {
for (int l = 1; l < k ; ++l) {
for (int m = 0; m < l; ++m) {
if (!(i-m == 4 || (i == 12 && j == 3))) {
mFlushRankPtr[face_flush[i] + face_flush[j] + face_flush[k] +
face_flush[l] + face_flush[m]] = n++;
mFlushRankPtr[face_flush[i] | face_flush[j] | face_flush[k] |
face_flush[l] | face_flush[m]] = n++;
}
}
}
Expand All @@ -125,13 +125,13 @@ mFlushRankPtr(new short unsigned[MAX_FIVE_FLUSH_KEY_INT+1]) {
}

// Low straight flush.
mFlushRankPtr[face_flush[0] + face_flush[1] + face_flush[2] +
face_flush[3] + face_flush[12]] = n++;
mFlushRankPtr[face_flush[0] | face_flush[1] | face_flush[2] |
face_flush[3] | face_flush[12]] = n++;

// Usual straight flush.
for (int i = 0; i < 9; ++i) {
mFlushRankPtr[face_flush[i] + face_flush[i+1] + face_flush[i+2] +
face_flush[i+3] + face_flush[i+4]] = n++;
mFlushRankPtr[face_flush[i] | face_flush[i+1] | face_flush[i+2] |
face_flush[i+3] | face_flush[i+4]] = n++;
}
}

Expand All @@ -147,10 +147,10 @@ short unsigned FiveEval::GetRank(int const card_one, int const card_two,
(mDeckcardsSuit[card_one] == mDeckcardsSuit[card_three]) &&
(mDeckcardsSuit[card_one] == mDeckcardsSuit[card_four]) &&
(mDeckcardsSuit[card_one] == mDeckcardsSuit[card_five])) {
return mFlushRankPtr[mDeckcardsFlush[card_one] +
mDeckcardsFlush[card_two] +
mDeckcardsFlush[card_three] +
mDeckcardsFlush[card_four] +
return mFlushRankPtr[mDeckcardsFlush[card_one] |
mDeckcardsFlush[card_two] |
mDeckcardsFlush[card_three] |
mDeckcardsFlush[card_four] |
mDeckcardsFlush[card_five]];
}
return mRankPtr[mDeckcardsFace[card_one] +
Expand Down

0 comments on commit 1786084

Please sign in to comment.