From 0f00e789af3e5b6b4891ec128172ed431bbff287 Mon Sep 17 00:00:00 2001 From: azriel1rf Date: Tue, 30 Apr 2024 18:49:50 +0900 Subject: [PATCH] Move `CardSampler` to separate files and use it in evaluation tests (#91) * Refactor card_sampler include paths in benchmark files * Refactor to use `card_sampler::CardSampler` in tests * Refactor card_sampler implementation to separate header and source files --- cpp/CMakeLists.txt | 8 ++ cpp/benchmark/benchmark.cc | 32 ++----- cpp/benchmark/benchmark_plo4.cc | 16 +--- cpp/benchmark/benchmark_plo5.cc | 20 ++-- cpp/benchmark/benchmark_plo6.cc | 20 ++-- cpp/benchmark/card_sampler.h | 30 ------ cpp/include/phevaluator/card_sampler.h | 21 +++++ cpp/src/card_sampler.cc | 30 ++++++ cpp/test/evaluation_plo4.cc | 99 ++++++-------------- cpp/test/evaluation_plo5.cc | 117 ++++++++--------------- cpp/test/evaluation_plo6.cc | 125 ++++++++----------------- 11 files changed, 196 insertions(+), 322 deletions(-) delete mode 100644 cpp/benchmark/card_sampler.h create mode 100644 cpp/include/phevaluator/card_sampler.h create mode 100644 cpp/src/card_sampler.cc diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 718d5d0..f84de18 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -19,6 +19,7 @@ option(BUILD_TESTS "Build test ON/OFF" ON) option(BUILD_EXAMPLES "Build examples ON/OFF" ON) add_library(pheval STATIC + src/card_sampler.cc src/dptables.c src/evaluator5.cc src/evaluator5.c @@ -41,6 +42,7 @@ target_include_directories(pheval PUBLIC target_compile_options(pheval PUBLIC -O3) set(PUB_HEADERS include/phevaluator/phevaluator.h include/phevaluator/card.h + include/phevaluator/card_sampler.h include/phevaluator/rank.h) set_target_properties(pheval PROPERTIES VERSION ${PROJECT_VERSION} @@ -114,6 +116,7 @@ endif() if (BUILD_PLO4) add_library(phevalplo4 STATIC + src/card_sampler.cc src/dptables.c src/evaluator_plo4.c src/evaluator_plo4.cc @@ -130,6 +133,7 @@ if (BUILD_PLO4) target_compile_options(phevalplo4 PUBLIC -O3) set(PUB_HEADERS include/phevaluator/phevaluator.h include/phevaluator/card.h + include/phevaluator/card_sampler.h include/phevaluator/rank.h) set_target_properties(phevalplo4 PROPERTIES VERSION ${PROJECT_VERSION} @@ -148,6 +152,7 @@ if (BUILD_PLO5) ) add_library(phevalplo5 STATIC + src/card_sampler.cc src/dptables.c src/evaluator_plo5.c src/evaluator_plo5.cc @@ -164,6 +169,7 @@ if (BUILD_PLO5) target_compile_options(phevalplo5 PUBLIC -O3) set(PUB_HEADERS include/phevaluator/phevaluator.h include/phevaluator/card.h + include/phevaluator/card_sampler.h include/phevaluator/rank.h) set_target_properties(phevalplo5 PROPERTIES VERSION ${PROJECT_VERSION} @@ -181,6 +187,7 @@ if (BUILD_PLO6) ) add_library(phevalplo6 STATIC + src/card_sampler.cc src/dptables.c src/evaluator_plo6.c src/evaluator_plo6.cc @@ -197,6 +204,7 @@ if (BUILD_PLO6) target_compile_options(phevalplo6 PUBLIC -O3) set(PUB_HEADERS include/phevaluator/phevaluator.h include/phevaluator/card.h + include/phevaluator/card_sampler.h include/phevaluator/rank.h) set_target_properties(phevalplo6 PROPERTIES VERSION ${PROJECT_VERSION} diff --git a/cpp/benchmark/benchmark.cc b/cpp/benchmark/benchmark.cc index 7beb31d..badb34c 100644 --- a/cpp/benchmark/benchmark.cc +++ b/cpp/benchmark/benchmark.cc @@ -1,6 +1,6 @@ -#include "phevaluator/phevaluator.h" #include "benchmark/benchmark.h" -#include "card_sampler.h" +#include "phevaluator/card_sampler.h" +#include "phevaluator/phevaluator.h" using namespace phevaluator; @@ -65,16 +65,13 @@ const int SIZE = 100; static void EvaluateRandomFiveCards(benchmark::State& state) { std::vector> hands; - CardSampler cs{}; + card_sampler::CardSampler cs{}; for (int i = 0; i < SIZE; i++) { hands.push_back(cs.sample(5)); } for (auto _ : state) { for (int i = 0; i < SIZE; i++) { - EvaluateCards(hands[i][0], - hands[i][1], - hands[i][2], - hands[i][3], + EvaluateCards(hands[i][0], hands[i][1], hands[i][2], hands[i][3], hands[i][4]); } } @@ -83,7 +80,7 @@ BENCHMARK(EvaluateRandomFiveCards); static void EvaluateRandomSixCards(benchmark::State& state) { std::vector> hands; - CardSampler cs{}; + card_sampler::CardSampler cs{}; for (int i = 0; i < SIZE; i++) { hands.push_back(cs.sample(6)); @@ -91,12 +88,8 @@ static void EvaluateRandomSixCards(benchmark::State& state) { for (auto _ : state) { for (int i = 0; i < SIZE; i++) { - EvaluateCards(hands[i][0], - hands[i][1], - hands[i][2], - hands[i][3], - hands[i][4], - hands[i][5]); + EvaluateCards(hands[i][0], hands[i][1], hands[i][2], hands[i][3], + hands[i][4], hands[i][5]); } } } @@ -104,7 +97,7 @@ BENCHMARK(EvaluateRandomSixCards); static void EvaluateRandomSevenCards(benchmark::State& state) { std::vector> hands; - CardSampler cs{}; + card_sampler::CardSampler cs{}; for (int i = 0; i < SIZE; i++) { hands.push_back(cs.sample(7)); @@ -112,13 +105,8 @@ static void EvaluateRandomSevenCards(benchmark::State& state) { for (auto _ : state) { for (int i = 0; i < SIZE; i++) { - EvaluateCards(hands[i][0], - hands[i][1], - hands[i][2], - hands[i][3], - hands[i][4], - hands[i][5], - hands[i][6]); + EvaluateCards(hands[i][0], hands[i][1], hands[i][2], hands[i][3], + hands[i][4], hands[i][5], hands[i][6]); } } } diff --git a/cpp/benchmark/benchmark_plo4.cc b/cpp/benchmark/benchmark_plo4.cc index 30d6eca..171e1af 100644 --- a/cpp/benchmark/benchmark_plo4.cc +++ b/cpp/benchmark/benchmark_plo4.cc @@ -1,6 +1,6 @@ -#include "phevaluator/phevaluator.h" #include "benchmark/benchmark.h" -#include "card_sampler.h" +#include "phevaluator/card_sampler.h" +#include "phevaluator/phevaluator.h" using namespace phevaluator; @@ -8,7 +8,7 @@ const int SIZE = 100; static void EvaluateRandomPlo4Cards(benchmark::State& state) { std::vector> hands; - CardSampler cs{}; + card_sampler::CardSampler cs{}; for (int i = 0; i < SIZE; i++) { hands.push_back(cs.sample(9)); @@ -16,14 +16,8 @@ static void EvaluateRandomPlo4Cards(benchmark::State& state) { for (auto _ : state) { for (int i = 0; i < SIZE; i++) { - EvaluatePlo4Cards(hands[i][0], - hands[i][1], - hands[i][2], - hands[i][3], - hands[i][4], - hands[i][5], - hands[i][6], - hands[i][7], + EvaluatePlo4Cards(hands[i][0], hands[i][1], hands[i][2], hands[i][3], + hands[i][4], hands[i][5], hands[i][6], hands[i][7], hands[i][8]); } } diff --git a/cpp/benchmark/benchmark_plo5.cc b/cpp/benchmark/benchmark_plo5.cc index ee77a45..0964ed3 100644 --- a/cpp/benchmark/benchmark_plo5.cc +++ b/cpp/benchmark/benchmark_plo5.cc @@ -1,15 +1,14 @@ -#include "phevaluator/phevaluator.h" #include "benchmark/benchmark.h" -#include "card_sampler.h" +#include "phevaluator/card_sampler.h" +#include "phevaluator/phevaluator.h" using namespace phevaluator; - const int SIZE = 100; static void EvaluateRandomPlo5Cards(benchmark::State& state) { std::vector> hands; - CardSampler cs{}; + card_sampler::CardSampler cs{}; for (int i = 0; i < SIZE; i++) { hands.push_back(cs.sample(10)); @@ -17,16 +16,9 @@ static void EvaluateRandomPlo5Cards(benchmark::State& state) { for (auto _ : state) { for (int i = 0; i < SIZE; i++) { - EvaluatePlo5Cards(hands[i][0], - hands[i][1], - hands[i][2], - hands[i][3], - hands[i][4], - hands[i][5], - hands[i][6], - hands[i][7], - hands[i][8], - hands[i][9]); + EvaluatePlo5Cards(hands[i][0], hands[i][1], hands[i][2], hands[i][3], + hands[i][4], hands[i][5], hands[i][6], hands[i][7], + hands[i][8], hands[i][9]); } } } diff --git a/cpp/benchmark/benchmark_plo6.cc b/cpp/benchmark/benchmark_plo6.cc index 4f5d494..faa66b4 100644 --- a/cpp/benchmark/benchmark_plo6.cc +++ b/cpp/benchmark/benchmark_plo6.cc @@ -1,6 +1,6 @@ -#include "phevaluator/phevaluator.h" #include "benchmark/benchmark.h" -#include "card_sampler.h" +#include "phevaluator/card_sampler.h" +#include "phevaluator/phevaluator.h" using namespace phevaluator; @@ -8,7 +8,7 @@ const int SIZE = 100; static void EvaluateRandomPlo6Cards(benchmark::State& state) { std::vector> hands; - CardSampler cs{}; + card_sampler::CardSampler cs{}; for (int i = 0; i < SIZE; i++) { hands.push_back(cs.sample(11)); @@ -16,17 +16,9 @@ static void EvaluateRandomPlo6Cards(benchmark::State& state) { for (auto _ : state) { for (int i = 0; i < SIZE; i++) { - EvaluatePlo6Cards(hands[i][0], - hands[i][1], - hands[i][2], - hands[i][3], - hands[i][4], - hands[i][5], - hands[i][6], - hands[i][7], - hands[i][8], - hands[i][9], - hands[i][10]); + EvaluatePlo6Cards(hands[i][0], hands[i][1], hands[i][2], hands[i][3], + hands[i][4], hands[i][5], hands[i][6], hands[i][7], + hands[i][8], hands[i][9], hands[i][10]); } } } diff --git a/cpp/benchmark/card_sampler.h b/cpp/benchmark/card_sampler.h deleted file mode 100644 index a013cf5..0000000 --- a/cpp/benchmark/card_sampler.h +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -static unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); -static std::default_random_engine generator(seed); - -class CardSampler { - std::array deck; -public: - CardSampler(void) { - std::iota(deck.begin(), deck.end(), 0); - } - std::vector sample(int size) { - std::vector ret; - int residual_cards = deck.size(); - for (int i = 0; i < size; i++) { - int target_index = generator() % residual_cards; - int tail_index = residual_cards - 1; - std::swap(deck[target_index], deck[tail_index]); - ret.push_back(deck[tail_index]); - residual_cards--; - } - return ret; - } -}; diff --git a/cpp/include/phevaluator/card_sampler.h b/cpp/include/phevaluator/card_sampler.h new file mode 100644 index 0000000..bfe2bd5 --- /dev/null +++ b/cpp/include/phevaluator/card_sampler.h @@ -0,0 +1,21 @@ +#pragma once +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +namespace card_sampler { +class CardSampler { + std::array deck; + + public: + CardSampler(void); + std::vector sample(int size); +}; +} // namespace card_sampler + +#ifdef __cplusplus +} // closing brace for extern "C" +#endif diff --git a/cpp/src/card_sampler.cc b/cpp/src/card_sampler.cc new file mode 100644 index 0000000..6b35487 --- /dev/null +++ b/cpp/src/card_sampler.cc @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include +#include + +namespace card_sampler { +static unsigned seed = + std::chrono::system_clock::now().time_since_epoch().count(); +static std::default_random_engine generator(seed); + +CardSampler::CardSampler(void) { + std::iota(deck.begin(), deck.end(), 0); +} + +std::vector CardSampler::sample(int size) { + std::vector ret; + int residual_cards = deck.size(); + for (int i = 0; i < size; i++) { + int target_index = generator() % residual_cards; + int tail_index = residual_cards - 1; + std::swap(deck[target_index], deck[tail_index]); + ret.push_back(deck[tail_index]); + residual_cards--; + } + return ret; +} +} // namespace card_sampler diff --git a/cpp/test/evaluation_plo4.cc b/cpp/test/evaluation_plo4.cc index 0ee4a85..0a7e712 100644 --- a/cpp/test/evaluation_plo4.cc +++ b/cpp/test/evaluation_plo4.cc @@ -1,11 +1,11 @@ -#include -#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include + #include "gtest/gtest.h" #include "kev/kev_eval.h" @@ -15,54 +15,25 @@ static int percentage(long long numerator, long long denominator) { return numerator * 100 / denominator; } -static unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); -static std::default_random_engine generator(seed); -static std::uniform_int_distribution distribution(0, 51); - -static std::vector RandomCardSample(int size) { - std::vector ret; - std::set sample; +static card_sampler::CardSampler cs{}; - while (sample.size() < size) { - int number = distribution(generator); - if (sample.find(number) == sample.end()) { - ret.push_back(number); - sample.insert(number); - } - } - - return ret; -} - -static short IterateKevEval(int a, int b, int c, int d, int e, - int f, int g, int h, int i) { +static short +IterateKevEval(int a, int b, int c, int d, int e, int f, int g, int h, int i) { short best = 20000; int board[10][3] = { - {a, b, c}, - {a, b, d}, - {a, b, e}, - {a, c, d}, - {a, c, e}, - {a, d, e}, - {b, c, d}, - {b, c, e}, - {b, d, e}, - {c, d, e}, + {a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e}, + {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}, }; int hole[6][2] = { - {f, g}, - {f, h}, - {f, i}, - {g, h}, - {g, i}, - {h, i}, + {f, g}, {f, h}, {f, i}, {g, h}, {g, i}, {h, i}, }; for (int j = 0; j < 10; j++) { for (int k = 0; k < 6; k++) { best = std::min(kev_eval_5cards(board[j][0], board[j][1], board[j][2], - hole[k][0], hole[k][1]), best); + hole[k][0], hole[k][1]), + best); } } @@ -76,32 +47,21 @@ TEST(EvaluationTest, TestPlo4Cards) { std::printf("Start testing Plo4 cards\n"); for (long long count = 0; count < total; count++) { - std::vector sample = RandomCardSample(9); - - int ph_eval = EvaluatePlo4Cards(sample[0], - sample[1], - sample[2], - sample[3], - sample[4], - sample[5], - sample[6], - sample[7], - sample[8]).value(); - - int kev_eval = IterateKevEval(sample[0], - sample[1], - sample[2], - sample[3], - sample[4], - sample[5], - sample[6], - sample[7], - sample[8]); - - EXPECT_EQ(ph_eval, kev_eval) << "Cards are: " - << sample[0] << ", " << sample[1] << ", " << sample[2] << ", " << sample[3] << ", " - << sample[4] << ", " << sample[5] << ", " << sample[6] << ", " << sample[7] << ", " - << sample[8] << ", "; + std::vector sample = cs.sample(9); + + int ph_eval = + EvaluatePlo4Cards(sample[0], sample[1], sample[2], sample[3], sample[4], + sample[5], sample[6], sample[7], sample[8]) + .value(); + + int kev_eval = + IterateKevEval(sample[0], sample[1], sample[2], sample[3], sample[4], + sample[5], sample[6], sample[7], sample[8]); + + EXPECT_EQ(ph_eval, kev_eval) + << "Cards are: " << sample[0] << ", " << sample[1] << ", " << sample[2] + << ", " << sample[3] << ", " << sample[4] << ", " << sample[5] << ", " + << sample[6] << ", " << sample[7] << ", " << sample[8] << ", "; if (percentage(count, total) > progress) { progress = percentage(count, total); @@ -114,4 +74,3 @@ TEST(EvaluationTest, TestPlo4Cards) { std::printf("Complete testing Plo4 cards\n"); std::printf("Tested %lld random hands in total\n", total); } - diff --git a/cpp/test/evaluation_plo5.cc b/cpp/test/evaluation_plo5.cc index f063db5..5dbf913 100644 --- a/cpp/test/evaluation_plo5.cc +++ b/cpp/test/evaluation_plo5.cc @@ -1,11 +1,11 @@ -#include -#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include + #include "gtest/gtest.h" #include "kev/kev_eval.h" @@ -15,58 +15,34 @@ static int percentage(long long numerator, long long denominator) { return numerator * 100 / denominator; } -static unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); -static std::default_random_engine generator(seed); -static std::uniform_int_distribution distribution(0, 51); - -static std::vector RandomCardSample(int size) { - std::vector ret; - std::set sample; - - while (sample.size() < size) { - int number = distribution(generator); - if (sample.find(number) == sample.end()) { - ret.push_back(number); - sample.insert(number); - } - } - - return ret; -} - -static short IterateKevEval(int a, int b, int c, int d, int e, - int f, int g, int h, int i, int j) { +static card_sampler::CardSampler cs{}; + +static short IterateKevEval(int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + int i, + int j) { short best = 20000; int board[10][3] = { - {a, b, c}, - {a, b, d}, - {a, b, e}, - {a, c, d}, - {a, c, e}, - {a, d, e}, - {b, c, d}, - {b, c, e}, - {b, d, e}, - {c, d, e}, + {a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e}, + {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}, }; int hole[10][2] = { - {f, g}, - {f, h}, - {f, i}, - {f, j}, - {g, h}, - {g, i}, - {g, j}, - {h, i}, - {h, j}, - {i, j}, + {f, g}, {f, h}, {f, i}, {f, j}, {g, h}, + {g, i}, {g, j}, {h, i}, {h, j}, {i, j}, }; for (int j = 0; j < 10; j++) { for (int k = 0; k < 10; k++) { best = std::min(kev_eval_5cards(board[j][0], board[j][1], board[j][2], - hole[k][0], hole[k][1]), best); + hole[k][0], hole[k][1]), + best); } } @@ -80,34 +56,22 @@ TEST(EvaluationTest, TestPlo5Cards) { std::printf("Start testing Plo5 cards\n"); for (long long count = 0; count < total; count++) { - std::vector sample = RandomCardSample(10); - - int ph_eval = EvaluatePlo5Cards(sample[0], - sample[1], - sample[2], - sample[3], - sample[4], - sample[5], - sample[6], - sample[7], - sample[8], - sample[9]).value(); - - int kev_eval = IterateKevEval(sample[0], - sample[1], - sample[2], - sample[3], - sample[4], - sample[5], - sample[6], - sample[7], - sample[8], - sample[9]); - - EXPECT_EQ(ph_eval, kev_eval) << "Cards are: " - << sample[0] << ", " << sample[1] << ", " << sample[2] << ", " << sample[3] << ", " - << sample[4] << ", " << sample[5] << ", " << sample[6] << ", " << sample[7] << ", " - << sample[8] << ", " << sample[9]; + std::vector sample = cs.sample(10); + + int ph_eval = + EvaluatePlo5Cards(sample[0], sample[1], sample[2], sample[3], sample[4], + sample[5], sample[6], sample[7], sample[8], sample[9]) + .value(); + + int kev_eval = + IterateKevEval(sample[0], sample[1], sample[2], sample[3], sample[4], + sample[5], sample[6], sample[7], sample[8], sample[9]); + + EXPECT_EQ(ph_eval, kev_eval) + << "Cards are: " << sample[0] << ", " << sample[1] << ", " << sample[2] + << ", " << sample[3] << ", " << sample[4] << ", " << sample[5] << ", " + << sample[6] << ", " << sample[7] << ", " << sample[8] << ", " + << sample[9]; if (percentage(count, total) > progress) { progress = percentage(count, total); @@ -120,4 +84,3 @@ TEST(EvaluationTest, TestPlo5Cards) { std::printf("Complete testing Plo5 cards\n"); std::printf("Tested %lld random hands in total\n", total); } - diff --git a/cpp/test/evaluation_plo6.cc b/cpp/test/evaluation_plo6.cc index 2810c6b..46c5a48 100644 --- a/cpp/test/evaluation_plo6.cc +++ b/cpp/test/evaluation_plo6.cc @@ -1,11 +1,11 @@ -#include -#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include + #include "gtest/gtest.h" #include "kev/kev_eval.h" @@ -15,63 +15,35 @@ static int percentage(long long numerator, long long denominator) { return numerator * 100 / denominator; } -static unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); -static std::default_random_engine generator(seed); -static std::uniform_int_distribution distribution(0, 51); - -static std::vector RandomCardSample(int size) { - std::vector ret; - std::set sample; - - while (sample.size() < size) { - int number = distribution(generator); - if (sample.find(number) == sample.end()) { - ret.push_back(number); - sample.insert(number); - } - } - - return ret; -} - -static short IterateKevEval(int a, int b, int c, int d, int e, - int f, int g, int h, int i, int j, int k) { +static card_sampler::CardSampler cs{}; + +static short IterateKevEval(int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + int i, + int j, + int k) { short best = 20000; int board[10][3] = { - {a, b, c}, - {a, b, d}, - {a, b, e}, - {a, c, d}, - {a, c, e}, - {a, d, e}, - {b, c, d}, - {b, c, e}, - {b, d, e}, - {c, d, e}, + {a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e}, + {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}, }; int hole[15][2] = { - {f, g}, - {f, h}, - {f, i}, - {f, j}, - {f, k}, - {g, h}, - {g, i}, - {g, j}, - {g, k}, - {h, i}, - {h, j}, - {h, k}, - {i, j}, - {i, k}, - {j, k}, + {f, g}, {f, h}, {f, i}, {f, j}, {f, k}, {g, h}, {g, i}, {g, j}, + {g, k}, {h, i}, {h, j}, {h, k}, {i, j}, {i, k}, {j, k}, }; for (int j = 0; j < 10; j++) { for (int k = 0; k < 15; k++) { best = std::min(kev_eval_5cards(board[j][0], board[j][1], board[j][2], - hole[k][0], hole[k][1]), best); + hole[k][0], hole[k][1]), + best); } } @@ -85,36 +57,22 @@ TEST(EvaluationTest, TestPlo6Cards) { std::printf("Start testing Plo6 cards\n"); for (long long count = 0; count < total; count++) { - std::vector sample = RandomCardSample(11); - - int ph_eval = EvaluatePlo6Cards(sample[0], - sample[1], - sample[2], - sample[3], - sample[4], - sample[5], - sample[6], - sample[7], - sample[8], - sample[9], - sample[10]).value(); - - int kev_eval = IterateKevEval(sample[0], - sample[1], - sample[2], - sample[3], - sample[4], - sample[5], - sample[6], - sample[7], - sample[8], - sample[9], - sample[10]); - - EXPECT_EQ(ph_eval, kev_eval) << "Cards are: " - << sample[0] << ", " << sample[1] << ", " << sample[2] << ", " << sample[3] << ", " - << sample[4] << ", " << sample[5] << ", " << sample[6] << ", " << sample[7] << ", " - << sample[8] << ", " << sample[9] << ", " << sample[10]; + std::vector sample = cs.sample(11); + + int ph_eval = EvaluatePlo6Cards(sample[0], sample[1], sample[2], sample[3], + sample[4], sample[5], sample[6], sample[7], + sample[8], sample[9], sample[10]) + .value(); + + int kev_eval = IterateKevEval(sample[0], sample[1], sample[2], sample[3], + sample[4], sample[5], sample[6], sample[7], + sample[8], sample[9], sample[10]); + + EXPECT_EQ(ph_eval, kev_eval) + << "Cards are: " << sample[0] << ", " << sample[1] << ", " << sample[2] + << ", " << sample[3] << ", " << sample[4] << ", " << sample[5] << ", " + << sample[6] << ", " << sample[7] << ", " << sample[8] << ", " + << sample[9] << ", " << sample[10]; if (percentage(count, total) > progress) { progress = percentage(count, total); @@ -127,4 +85,3 @@ TEST(EvaluationTest, TestPlo6Cards) { std::printf("Complete testing Plo6 cards\n"); std::printf("Tested %lld random hands in total\n", total); } -