MCPcopy Create free account
hub / github.com/dds-bridge/dds / Par

Function Par

library/src/par.cpp:108–214  ·  view source on GitHub ↗

* @brief Compute the par score and contracts for both sides given double dummy results. * * This function analyzes the double dummy table results and determines the par score * and contracts for both North-South and East-West, based on vulnerability. * * @param tablep Pointer to double dummy table results * @param presp Pointer to result structure for par analysis * @param vulnerable Vulner

Source from the content-addressed store, hash-verified

106 * @return 1 on success, error code otherwise
107 */
108int STDCALL Par(
109 DdTableResults const * tablep,
110 ParResults * presp,
111 int vulnerable)
112{
113 /* vulnerable 0: None 1: Both 2: NS 3: EW */
114
115 /* The code for calculation of par score / contracts is based upon the
116 perl code written by Matthew Kidd ACBLmerge. He has kindly given me
117 permission to include a C++ adaptation in DDS. */
118
119 /* The Par function computes the par result and contracts. */
120
121 ParResultsMaster sidesRes[2];
122 int res, k;
123 char temp[8], buff[3];
124 int denom_conv[5] = { 4, 0, 1, 2, 3 };
125 char contr_sep[2] = { ',', '\0' };
126 char seats[6][4] = {
127 { "N " }, { "E " }, { "S " }, { "W " }, { "NS " }, { "EW " } };
128
129 res = SidesParBin(tablep, sidesRes, vulnerable);
130
131 if (res != RETURN_NO_FAULT)
132 return res;
133
134 presp->par_score[0][0] = 'N';
135 presp->par_score[0][1] = 'S';
136 presp->par_score[0][2] = ' ';
137 presp->par_score[0][3] = '\0';
138 presp->par_score[1][0] = 'E';
139 presp->par_score[1][1] = 'W';
140 presp->par_score[1][2] = ' ';
141 presp->par_score[1][3] = '\0';
142
143 snprintf(temp, 8, "%d", sidesRes[0].score);
144 strcat(presp->par_score[0], temp);
145 snprintf(temp, 8, "%d", sidesRes[1].score);
146 strcat(presp->par_score[1], temp);
147
148 presp->par_contracts_string[0][0] = 'N';
149 presp->par_contracts_string[0][1] = 'S';
150 presp->par_contracts_string[0][2] = ':';
151 presp->par_contracts_string[0][3] = '\0';
152 presp->par_contracts_string[1][0] = 'E';
153 presp->par_contracts_string[1][1] = 'W';
154 presp->par_contracts_string[1][2] = ':';
155 presp->par_contracts_string[1][3] = '\0';
156
157 if (sidesRes[0].score == 0)
158 {
159 /* Neither side can make anything.*/
160
161 return RETURN_NO_FAULT;
162 }
163
164 for (int i = 0; i <= 1; i++)
165 {

Callers 8

calc_parFunction · 0.85
calc_par_from_tableFunction · 0.85
CalcParFunction · 0.85
CalcAllTablesFunction · 0.85
loop_parFunction · 0.85
register_par_bindingsFunction · 0.85
mainFunction · 0.85
example_without_contextFunction · 0.85

Calls 2

SidesParBinFunction · 0.85
CalcMultiContractsFunction · 0.85

Tested by 1

loop_parFunction · 0.68