Bridge Calculator C API
C API for Bridge Calculator double dummy solver by Piotr Beling
 All Files Functions Typedefs Macros Pages
bcalcdds.h
Go to the documentation of this file.
1 #ifndef __BELING__BCALC_BRIDGE_SOLVER__
2 #define __BELING__BCALC_BRIDGE_SOLVER__
3 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
71 #define BCALC_VERSION 14020
72 
81 typedef struct BCalcDDS BCalcDDS;
82 
83 #define BCALC_PLAYER_NORTH 0
84 #define BCALC_PLAYER_EAST 1
85 #define BCALC_PLAYER_SOUTH 2
86 #define BCALC_PLAYER_WEST 3
87 
88 
93 #define bcalc_playerSymbol(player) ("NESW"[player])
94 
101 #define bcalc_nextHand(hand, delta) (((hand)+(delta))&3) //or (((hand)+(delta))%4)
102 
108 #define bcalc_declarerToLeader(declarer) bcalc_nextHand(declarer, 3)
109 
110 #define BCALC_SUIT_CLUBS 0
111 #define BCALC_SUIT_DIAMONDS 1
112 #define BCALC_SUIT_HEARTS 2
113 #define BCALC_SUIT_SPADES 3
114 
115 #define BCALC_NT 4
116 
117 
122 #define bcalc_suitSymbol(suit) ("CDHSN"[suit])
123 
129 unsigned bcalc_runtimeVersion();
130 
149 extern BCalcDDS* bcalcDDS_new(const char* format, const char* hands, int strain, int leader);
150 
157 extern BCalcDDS* bcalcDDS_clone(BCalcDDS* to_clone);
158 
163 extern void bcalcDDS_delete(BCalcDDS* solver);
164 
170 extern const char* bcalcDDS_getLastError(const BCalcDDS* solver);
171 
178 extern void bcalcDDS_clearError(BCalcDDS* solver);
179 
192 extern void bcalcDDS_exec(BCalcDDS* solver, const char* cmds);
193 
199 extern int bcalcDDS_getTricksToTake(BCalcDDS* solver);
200 
213 extern int bcalcDDS_getTricksToTakeEx(BCalcDDS* solver, int tricks_target, const char* card);
214 
220 extern int bcalcDDS_getTrump(BCalcDDS* solver);
221 
227 extern void bcalcDDS_setTrumpAndReset(BCalcDDS* solver, int new_trump);
228 
238 extern void bcalcDDS_setPlayerOnLeadAndReset(BCalcDDS* solver, int new_leader);
239 
246 extern int* bcalcDDS_getTricksTaken(BCalcDDS* solver, int* result);
247 
253 extern int bcalcDDS_getCardsLeftCount(BCalcDDS* solver);
254 
264 extern char* bcalcDDS_getCards(BCalcDDS* solver, char* result, int player, int suit);
265 
271 extern int bcalcDDS_getPlayerToPlay(BCalcDDS* solver);
272 
281 extern char* bcalcDDS_getCardsToPlay(BCalcDDS* solver, char* result, int suit);
282 
294 extern int bcalcDDS_getPlayedCard(BCalcDDS* solver, unsigned whenIndex, int* suit, char* cardSymbol);
295 
301 extern int bcalcDDS_getPlayedCardsCount(BCalcDDS* solver);
302 
303 #ifdef __cplusplus
304 }
305 #endif
306 
307 #endif //__BELING__BCALC_BRIDGE_SOLVER__
void bcalcDDS_exec(BCalcDDS *solver, const char *cmds)
Execute commands which can modify the state of given solver (current situation in game represented by...
unsigned bcalc_runtimeVersion()
Get the version of the API used by the runtime library.
int bcalcDDS_getCardsLeftCount(BCalcDDS *solver)
Get number of cards which left to play in game connected with solver.
int bcalcDDS_getTricksToTakeEx(BCalcDDS *solver, int tricks_target, const char *card)
If tricks_target == -1, calculate number of tricks possible to take.
int bcalcDDS_getPlayedCardsCount(BCalcDDS *solver)
Get number of cards which have been already played.
int bcalcDDS_getTrump(BCalcDDS *solver)
Get strain.
BCalcDDS * bcalcDDS_new(const char *format, const char *hands, int strain, int leader)
Construct new solver.
void bcalcDDS_delete(BCalcDDS *solver)
Delete double dummy solver, free its memory.
BCalcDDS * bcalcDDS_clone(BCalcDDS *to_clone)
Clone the state of the solver to_clone.
int bcalcDDS_getPlayerToPlay(BCalcDDS *solver)
Get player which should play now.
void bcalcDDS_setPlayerOnLeadAndReset(BCalcDDS *solver, int new_leader)
Reset deal to initial state (undo all tricks) and change player on lead.
struct BCalcDDS BCalcDDS
Handler to bcalc double dummy solver.
Definition: bcalcdds.h:81
char * bcalcDDS_getCardsToPlay(BCalcDDS *solver, char *result, int suit)
Get cards possible to play in given suit by player who should play.
char * bcalcDDS_getCards(BCalcDDS *solver, char *result, int player, int suit)
Get cards owned by given player in given suit.
void bcalcDDS_clearError(BCalcDDS *solver)
Clear error message.
int bcalcDDS_getTricksToTake(BCalcDDS *solver)
Calculate number of tricks possible to take (same as bcalcDDS_getTricksToTakeEx(solver, -1, 0)).
const char * bcalcDDS_getLastError(const BCalcDDS *solver)
Get last error string.
void bcalcDDS_setTrumpAndReset(BCalcDDS *solver, int new_trump)
Set new strain and reset deal to initial state (undo all tricks).
int bcalcDDS_getPlayedCard(BCalcDDS *solver, unsigned whenIndex, int *suit, char *cardSymbol)
Get card played as a whenIndex (when card played on first lead has index 0).
int * bcalcDDS_getTricksTaken(BCalcDDS *solver, int *result)
Get numbers of tricks which have been already taken by players in game connected with solver...