Placeholder for the rest of the functions to be moved
| 333 | |
| 334 | // Placeholder for the rest of the functions to be moved |
| 335 | void weight_alloc_nt0(HeuristicContext& context) { |
| 336 | int aggr = context.tpos.aggr[context.suit]; |
| 337 | |
| 338 | /* Discourage a suit selection where the search tree appears larger |
| 339 | than for the alternative suits: the search is estimated to be |
| 340 | small when the added number of alternative cards to play for |
| 341 | the opponents is small. */ |
| 342 | |
| 343 | unsigned short suit_count_lh = context.tpos.length[lho[context.lead_hand]][context.suit]; |
| 344 | unsigned short suit_count_rh = context.tpos.length[rho[context.lead_hand]][context.suit]; |
| 345 | |
| 346 | // Why? |
| 347 | int countLH = (suit_count_lh == 0 ? context.curr_trick + 1 : suit_count_lh) << 2; |
| 348 | int countRH = (suit_count_rh == 0 ? context.curr_trick + 1 : suit_count_rh) << 2; |
| 349 | |
| 350 | int suit_weight_d = - (((countLH + countRH) << 5) / 19); |
| 351 | if (context.tpos.length[partner[context.lead_hand]][context.suit] == 0) |
| 352 | suit_weight_d += -9; |
| 353 | |
| 354 | for (int k = context.last_num_moves; k < context.num_moves; k++) |
| 355 | { |
| 356 | int suit_weight_delta = suit_weight_d; |
| 357 | int r_rank = rel_rank[aggr][context.mply[k].rank]; |
| 358 | |
| 359 | if (context.tpos.winner[context.suit].rank == context.mply[k].rank || |
| 360 | (context.tpos.rank_in_suit[partner[context.lead_hand]][context.suit] > |
| 361 | (context.tpos.rank_in_suit[lho[context.lead_hand]][context.suit] | |
| 362 | context.tpos.rank_in_suit[rho[context.lead_hand]][context.suit]))) |
| 363 | { |
| 364 | // Can win trick, ourselves or partner. |
| 365 | // FIX: No distinction? |
| 366 | /* Discourage suit if RHO has second best card. |
| 367 | Exception: RHO has singleton. */ |
| 368 | if (context.tpos.second_best[context.suit].hand == rho[context.lead_hand]) |
| 369 | { |
| 370 | if (suit_count_rh != 1) |
| 371 | suit_weight_delta += -1; |
| 372 | } |
| 373 | /* Encourage playing suit if LHO has second highest rank. */ |
| 374 | else if (context.tpos.second_best[context.suit].hand == lho[context.lead_hand]) |
| 375 | { |
| 376 | if (suit_count_lh != 1) |
| 377 | suit_weight_delta += 22; |
| 378 | else |
| 379 | suit_weight_delta += 16; |
| 380 | } |
| 381 | |
| 382 | /* Higher weight if also second best rank is present on |
| 383 | current side to play, or if second best is a singleton |
| 384 | at LHO or RHO. */ |
| 385 | |
| 386 | if (((context.tpos.second_best[context.suit].hand != lho[context.lead_hand]) |
| 387 | || (suit_count_lh == 1)) && |
| 388 | ((context.tpos.second_best[context.suit].hand != rho[context.lead_hand]) |
| 389 | || (suit_count_rh == 1))) |
| 390 | context.mply[k].weight = suit_weight_delta + 45 + r_rank; |
| 391 | else |
| 392 | context.mply[k].weight = suit_weight_delta + 18 + r_rank; |
no outgoing calls