Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add dead cards option for evaluation #82

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/pokerstove/penum/ShowdownEnumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ShowdownEnumerator::ShowdownEnumerator() {}

vector<EquityResult> ShowdownEnumerator::calculateEquity(const vector<CardDistribution>& dists,
const CardSet& board,
const CardSet& dead_cards,
boost::shared_ptr<PokerHandEvaluator> peval) const
{
if (peval.get() == NULL)
Expand Down Expand Up @@ -90,6 +91,7 @@ vector<EquityResult> ShowdownEnumerator::calculateEquity(const vector<CardDistri
{
deck.reset();
deck.remove(dead);
deck.remove(dead_cards);
PartitionEnumerator2 pe(deck.size(), parts);
do
{
Expand Down
1 change: 1 addition & 0 deletions src/lib/pokerstove/penum/ShowdownEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ShowdownEnumerator
std::vector<EquityResult>
calculateEquity(const std::vector<CardDistribution>& dists,
const CardSet& board,
const CardSet& dead_cards,
boost::shared_ptr<PokerHandEvaluator> peval) const;
};
} // namespace pokerstove
Expand Down
1 change: 1 addition & 0 deletions src/lib/pokerstove/peval/CardSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void CardSet::fromString(const string& instr)
i -= 1;
continue;
}

int code = Rank::rank_code(instr[i]) +
Suit::suit_code(instr[i + 1]) * Rank::NUM_RANK;
uint64_t mask = (ONE64 << code);
Expand Down
4 changes: 3 additions & 1 deletion src/programs/ps-eval/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ int main(int argc, char** argv)
("game,g", po::value<string>()->default_value("h"), "game to use for evaluation")
("board,b", po::value<string>(), "community cards for he/o/o8")
("hand,h", po::value<vector<string>>(), "a hand for evaluation")
("dead,d", po::value<string>(), "dead cards for evaluation")
("quiet,q", "produces no output");

// make hand a positional argument
Expand All @@ -41,6 +42,7 @@ int main(int argc, char** argv)
// extract the options
string game = vm["game"].as<string>();
string board = vm.count("board") ? vm["board"].as<string>() : "";
string dead = vm.count("dead") ? vm["dead"].as<string>() : "";
vector<string> hands = vm["hand"].as<vector<string>>();

bool quiet = vm.count("quiet") > 0;
Expand All @@ -65,7 +67,7 @@ int main(int argc, char** argv)
// calcuate the results and print them
ShowdownEnumerator showdown;
vector<EquityResult> results =
showdown.calculateEquity(handDists, CardSet(board), evaluator);
showdown.calculateEquity(handDists, CardSet(board), CardSet(dead), evaluator);

double total = 0.0;
for (const EquityResult& result : results)
Expand Down