Hi folks,
I am trying to use the PokerSource eval package to enumerate and
evaluate all the first 2 hole cards for texas holdem. The good news
is I got it to work (which as a windows user was a bit of a feat).
The bad news is I am not that happy w/ my src, or my results.
Anyone want to comment on either? Apologies, I don't know how to
attach a file, so I am gonna paste my src here. Not too huge.
Things bothering me:
1) the results. According to my results, pairs rule! The the point
of 8,8 being better than A,K suited. That doesn't sound right to
me. If I had to guess, its in the way I handle ties.
2) I couldn't figure out a good way to enumerate all the possible
hands, without having a bunch of duplicatation (like evaluating both
unsuited combos, Ac 7s and As 7c).
3) The enumerations I *do* use in main() are only 1 card, and use a
dead mask that was setup in a freaky loop.
Thanks for any comments.
-Scott
#include <stdio.h>
#include <stdlib.h>
#include "poker_defs.h"
#include "inlines/eval.h"
void print_ev(CardMask my_cards)
{
float ev;
unsigned long win, lose, tie;
unsigned long my_val, their_val;
CardMask all_mine, all_theirs, board_cards;
CardMask their_cards;
win = 0;
lose = 0;
tie = 0;
ev = 0.0;
// for every set of board cards, that exclude mine
ENUMERATE_N_CARDS_D(board_cards, 5, my_cards,
{
// calculate a value for my 7 cards (pocket + board)
CardMask_OR(all_mine, board_cards, my_cards);
my_val = Hand_EVAL_N(all_mine, 7);
// for every set of opponent hands, that exclude my cards
and the board cards
ENUMERATE_N_CARDS_D(their_cards, 2, all_mine,
{
// calculate a value for their 7 card hand (2 pocket in
their_cards + 5 board_cards)
CardMask_OR(all_theirs, board_cards,
their_cards);
their_val = Hand_EVAL_N(all_theirs, 7);
if (their_val > my_val)
lose++;
else if (their_val < my_val)
win++;
else
tie++;
});
});
ev = (win + tie/2.0f) / (float)(win + lose + tie);
printf("%12d %12d %12d %0.3f\n", win, lose, tie, ev);
}
int main( int argc, char *argv[] )
{
int i = 1, c1, c2;
CardMask my_1st_card, my_2nd_card, my_cards;
CardMask hearts_diamonds_clubs, hearts_diamonds_spades,
my_card_mask;
// setup masks
StdDeck_CardMask_RESET(hearts_diamonds_clubs);
StdDeck_CardMask_RESET(hearts_diamonds_spades);
for (c1 = 0; c1 < 52; c1++)
{
if (StdDeck_SUIT(c1) != Suit_SPADES)
StdDeck_CardMask_SET(hearts_diamonds_clubs, c1);
if (StdDeck_SUIT(c1) != Suit_CLUBS)
StdDeck_CardMask_SET(hearts_diamonds_spades, c1);
}
printf(" win lose tie
ev\n");
my_card_mask = hearts_diamonds_clubs;
// for all possible spades
ENUMERATE_1_CARDS_D(my_1st_card, hearts_diamonds_clubs,
{
StdDeck_CardMask_OR(my_card_mask, my_card_mask, my_1st_card);
// for all spades, that exclude cards already seen in 1st
slot
ENUMERATE_1_CARDS_D(my_2nd_card, my_card_mask,
{
StdDeck_CardMask_OR(my_cards, my_1st_card, my_2nd_card);
printf("%4d [%s] ", i++, Deck_maskString
(my_cards));
print_ev(my_cards);
});
});
my_card_mask = hearts_diamonds_spades;
// print ev of all unsuited cards
for (c1 = StdDeck_Rank_FIRST; c1 <= StdDeck_Rank_LAST; c1++)
{
// for all clubs, that exclude cards of a rank higher than
already processed
for (c2 = c1; c2 <= StdDeck_Rank_LAST; c2++)
{
CardMask_RESET(my_cards);
CardMask_SET(my_cards, StdDeck_MAKE_CARD(c1,
Suit_SPADES));
CardMask_SET(my_cards, StdDeck_MAKE_CARD(c2,
Suit_CLUBS));
printf("%4d [%s] ", i++, Deck_maskString
(my_cards));
print_ev(my_cards);
}
}
return 0;
}