| 1107 | |
| 1108 | |
| 1109 | EvalType evaluate_with_context( |
| 1110 | Pos const * posPoint, |
| 1111 | const int trump, |
| 1112 | SolverContext& ctx) |
| 1113 | { |
| 1114 | auto thrp = ctx.thread(); |
| 1115 | int s, h, hmax = 0, count = 0, k = 0; |
| 1116 | unsigned short rmax = 0; |
| 1117 | EvalType eval; |
| 1118 | |
| 1119 | int firstHand = posPoint->first[0]; |
| 1120 | assert((firstHand >= 0) && (firstHand <= 3)); |
| 1121 | |
| 1122 | for (s = 0; s < DDS_SUITS; s++) |
| 1123 | eval.win_ranks[s] = 0; |
| 1124 | |
| 1125 | /* Who wins the last trick? */ |
| 1126 | if (trump != DDS_NOTRUMP) /* Highest trump card wins */ |
| 1127 | { |
| 1128 | for (h = 0; h < DDS_HANDS; h++) |
| 1129 | { |
| 1130 | if (posPoint->rank_in_suit[h][trump] != 0) |
| 1131 | count++; |
| 1132 | if (posPoint->rank_in_suit[h][trump] > rmax) |
| 1133 | { |
| 1134 | hmax = h; |
| 1135 | rmax = posPoint->rank_in_suit[h][trump]; |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | if (rmax > 0) /* Trumpcard wins */ |
| 1140 | { |
| 1141 | if (count >= 2) |
| 1142 | eval.win_ranks[trump] = rmax; |
| 1143 | |
| 1144 | if (ctx.search().node_type_store(hmax) == MAXNODE) |
| 1145 | goto maxexit; |
| 1146 | else |
| 1147 | goto minexit; |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | /* Who has the highest card in the suit played by 1st hand? */ |
| 1152 | |
| 1153 | k = 0; |
| 1154 | while (k <= 3) /* Find the card the 1st hand played */ |
| 1155 | { |
| 1156 | if (posPoint->rank_in_suit[firstHand][k] != 0) /* Is this the card? */ |
| 1157 | break; |
| 1158 | k++; |
| 1159 | } |
| 1160 | |
| 1161 | assert(k < 4); |
| 1162 | |
| 1163 | for (h = 0; h < DDS_HANDS; h++) |
| 1164 | { |
| 1165 | if (posPoint->rank_in_suit[h][k] != 0) |
| 1166 | count++; |
no test coverage detected