1 /*
2  * Copyright (C) 2002-2006
3  *           Michael Maurer <mjmaurer@yahoo.com>
4  *           Loic Dachary <loic@dachary.org>
5  *
6  * This program gives you software freedom; you can copy, convey,
7  * propagate, redistribute and/or modify this program under the terms of
8  * the GNU General Public License (GPL) as published by the Free Software
9  * Foundation (FSF), either version 3 of the License, or (at your option)
10  * any later version of the GPL published by the FSF.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program in a file in the toplevel directory called "GPLv3".
19  * If not, see <http://www.gnu.org/licenses/>.
20  */
21 /* $Id: enumdefs.h 5146 2008-12-04 03:11:22Z bkuhn $ */
22 
23 #ifndef ENUMDEFS_H
24 #define ENUMDEFS_H
25 
26 #include "enumord.h"
27 #include "pokereval_export.h"
28 
29 #define ENUM_MAXPLAYERS 12
30 
31 typedef enum {
32   /* do not reorder -- some other static arrays depend on this order */
33   game_holdem,
34   game_holdem8,
35   game_omaha,
36   game_omaha8,
37   game_7stud,
38   game_7stud8,
39   game_7studnsq,
40   game_razz,
41   game_5draw,
42   game_5draw8,
43   game_5drawnsq,
44   game_lowball,
45   game_lowball27,
46   game_NUMGAMES
47 } enum_game_t;
48 
49 typedef struct {
50   enum_game_t	game;
51   int           minpocket;
52   int           maxpocket;
53   int          	maxboard;
54   int		haslopot;
55   int		hashipot;
56   char *	name;
57 } enum_gameparams_t;
58 
59 typedef enum { ENUM_EXHAUSTIVE, ENUM_SAMPLE } enum_sample_t;
60 
61 typedef struct {
62   enum_game_t game;
63   enum_sample_t sampleType;
64   unsigned int nsamples;
65   unsigned int nplayers;
66   unsigned int nwinhi[ENUM_MAXPLAYERS];	/* qualifies for high and wins (no tie) */
67   unsigned int ntiehi[ENUM_MAXPLAYERS];	/* qualifies for high and ties */
68   unsigned int nlosehi[ENUM_MAXPLAYERS];/* qualifies for high and loses */
69   unsigned int nwinlo[ENUM_MAXPLAYERS];	/* qualifies for low and wins (no tie) */
70   unsigned int ntielo[ENUM_MAXPLAYERS];	/* qualifies for low and ties */
71   unsigned int nloselo[ENUM_MAXPLAYERS];/* qualifies for low and loses */
72   unsigned int nscoop[ENUM_MAXPLAYERS]; /* wins entire pot */
73 
74   /* nsharehi[i][H] is the number of times that player i tied for the best
75      high hand with H total players (including player i), or received no
76      share of the pot if H=0; likewise for nsharelo. */
77   unsigned int nsharehi[ENUM_MAXPLAYERS][ENUM_MAXPLAYERS+1];
78   unsigned int nsharelo[ENUM_MAXPLAYERS][ENUM_MAXPLAYERS+1];
79 
80   /* nshare[i][H][L] is the number of times that player i tied for the best
81      high hand with H total players (including player i) and simultaneously
82      tied for the best low hand with L total players (including player i),
83      where H=0 and L=0 indicate that player i did not win the corresponding
84      share of the pot.  For example, nshare[i][1][1] is the number of times
85      that player i scooped both high and low; nshare[i][1][2] is the number of
86      times that player i won high and split low with one player.  Note that
87      the H=0 and L=0 buckets include cases where player i didn't qualify
88      (e.g., for an 8-or-better low), which differs from the definition of
89      nlosehi[] and nloselo[] above.  So you can't compute ev[] from
90      nshare[][][]. */
91   unsigned int nshare[ENUM_MAXPLAYERS][ENUM_MAXPLAYERS+1][ENUM_MAXPLAYERS+1];
92 
93   /* ev[i] is the pot equity of player i averaged over all outcomes */
94   double ev[ENUM_MAXPLAYERS];
95 
96   enum_ordering_t *ordering;	/* detailed relative hand rank ordering */
97 } enum_result_t;
98 
99 extern POKEREVAL_EXPORT void enumResultPrint(enum_result_t *result, StdDeck_CardMask pockets[],
100                             StdDeck_CardMask board);
101 extern POKEREVAL_EXPORT void enumResultPrintTerse(enum_result_t *result,
102                                  StdDeck_CardMask pockets[],
103                                  StdDeck_CardMask board);
104 extern POKEREVAL_EXPORT void enumResultClear(enum_result_t *result);
105 extern POKEREVAL_EXPORT void enumResultFree(enum_result_t *result);
106 extern POKEREVAL_EXPORT int enumResultAlloc(enum_result_t *result, int nplayers,
107                            enum_ordering_mode_t mode);
108 extern POKEREVAL_EXPORT int enumExhaustive(enum_game_t game, StdDeck_CardMask pockets[],
109                           StdDeck_CardMask board, StdDeck_CardMask dead,
110                           int npockets, int nboard, int orderflag,
111                           enum_result_t *result);
112 extern POKEREVAL_EXPORT int enumSample(enum_game_t game, StdDeck_CardMask pockets[],
113                       StdDeck_CardMask board, StdDeck_CardMask dead,
114                       int npockets, int nboard, int niter, int orderflag,
115                       enum_result_t *result);
116 extern POKEREVAL_EXPORT enum_gameparams_t *enumGameParams(enum_game_t game);
117 
118 #endif
119