* @brief Analyze the number of quick tricks available for a given position. * * This function estimates the number of immediate tricks that can be taken * from the current position, hand, depth, target, and trump suit using double dummy logic. * * @param tpos Position state * @param hand Current hand * @param depth Current search depth * @param target Target number of tricks * @param trum
| 116 | * @return Number of quick tricks found |
| 117 | */ |
| 118 | int QuickTricks( |
| 119 | Pos& tpos, |
| 120 | const int hand, |
| 121 | const int depth, |
| 122 | const int target, |
| 123 | const int trump, |
| 124 | bool& result, |
| 125 | SolverContext& ctx) |
| 126 | { |
| 127 | int suit, commRank = 0, commSuit = -1; |
| 128 | int res; |
| 129 | int lhoTrumpRanks = 0, rhoTrumpRanks = 0; |
| 130 | int cutoff, lowestQtricks = 0; |
| 131 | |
| 132 | result = true; |
| 133 | int qtricks = 0; |
| 134 | |
| 135 | if (ctx.search().node_type_store(hand) == MAXNODE) |
| 136 | cutoff = target - tpos.tricks_max; |
| 137 | else |
| 138 | cutoff = tpos.tricks_max - target + (depth >> 2) + 2; |
| 139 | |
| 140 | bool commPartner = false; |
| 141 | const unsigned short (* ris)[DDS_SUITS] = tpos.rank_in_suit; |
| 142 | const unsigned char (* len)[DDS_SUITS] = tpos.length; |
| 143 | HighCardType const * winner = tpos.winner; |
| 144 | |
| 145 | for (int s = 0; s < DDS_SUITS; s++) |
| 146 | { |
| 147 | if ((trump != DDS_NOTRUMP) && (trump != s)) |
| 148 | { |
| 149 | /* Trump game, and we lead a non-trump suit */ |
| 150 | if (winner[s].hand == partner[hand]) |
| 151 | { |
| 152 | /* Partner has winning card */ |
| 153 | if (ris[hand][s] != 0 && /* Own hand has card */ |
| 154 | (((ris[lho[hand]][s] != 0) || /* LHO not void */ |
| 155 | (ris[lho[hand]][trump] == 0)) && /* LHO no trump */ |
| 156 | ((ris[rho[hand]][s] != 0) || /* RHO not void */ |
| 157 | (ris[rho[hand]][trump] == 0)))) /* RHO no trump */ |
| 158 | { |
| 159 | commPartner = true; |
| 160 | commSuit = s; |
| 161 | commRank = winner[s].rank; |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | else if ((tpos.second_best[s].hand == partner[hand]) && |
| 166 | (winner[s].hand == hand) && |
| 167 | (len[hand][s] >= 2) && |
| 168 | (len[partner[hand]][s] >= 2)) |
| 169 | { |
| 170 | /* Can cross to partner's card: Type Kx opposite Ax */ |
| 171 | if (((ris[lho[hand]][s] != 0) || /* LHO not void */ |
| 172 | (ris[lho[hand]][trump] == 0)) /* LHO no trump */ |
| 173 | && ((ris[rho[hand]][s] != 0) || /* RHO not void */ |
| 174 | (ris[rho[hand]][trump] == 0))) /* RHO no trump */ |
| 175 | { |
no test coverage detected