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

Function QuickTricksSecondHand

library/src/quick_tricks.cpp:1132–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1130
1131
1132bool QuickTricksSecondHand(
1133 Pos& tpos,
1134 const int hand,
1135 const int depth,
1136 const int target,
1137 const int trump,
1138 SolverContext& ctx)
1139{
1140 if (depth == ctx.search().ini_depth())
1141 return false;
1142
1143 int ss = tpos.move[depth + 1].suit;
1144 unsigned short (*ris)[DDS_SUITS] = tpos.rank_in_suit;
1145 unsigned short ranks = static_cast<unsigned short>
1146 (ris[hand][ss] | ris[partner[hand]][ss]);
1147
1148 for (int s = 0; s < DDS_SUITS; s++)
1149 tpos.win_ranks[depth][s] = 0;
1150
1151 if ((trump != DDS_NOTRUMP) && (ss != trump) &&
1152 (((ris[hand][ss] == 0) && (ris[hand][trump] != 0)) ||
1153 ((ris[partner[hand]][ss] == 0) &&
1154 (ris[partner[hand]][trump] != 0))))
1155 {
1156 if ((ris[lho[hand]][ss] == 0) &&
1157 (ris[lho[hand]][trump] != 0))
1158 return false;
1159
1160 /* Own side can ruff, their side can't. */
1161 }
1162
1163 else if (ranks > (bit_map_rank[tpos.move[depth + 1].rank] |
1164 ris[lho[hand]][ss]))
1165 {
1166 if ((trump != DDS_NOTRUMP) && (ss != trump) &&
1167 (ris[lho[hand]][trump] != 0) &&
1168 (ris[lho[hand]][ss] == 0))
1169 return false;
1170
1171 /* Own side has highest card in suit, which LHO can't ruff. */
1172
1173 int rr = highest_rank[ranks];
1174 tpos.win_ranks[depth][ss] = bit_map_rank[rr];
1175 }
1176 else
1177 {
1178 /* No easy way to win current trick for own side. */
1179 return false;
1180 }
1181
1182 int qtricks = 1;
1183
1184 int cutoff;
1185 if (ctx.search().node_type_store(hand) == MAXNODE)
1186 cutoff = target - tpos.tricks_max;
1187 else
1188 cutoff = tpos.tricks_max - target + (depth >> 2) + 3;
1189

Callers 1

ab_search_1_ctxFunction · 0.85

Calls 3

ini_depthMethod · 0.80
searchMethod · 0.80
node_type_storeMethod · 0.80

Tested by

no test coverage detected