-
Notifications
You must be signed in to change notification settings - Fork 1
/
CueBidConvention.cpp
756 lines (684 loc) · 23.3 KB
/
CueBidConvention.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
//----------------------------------------------------------------------------------------
//
// This file and all other Easy Bridge source files are copyright (C) 2002 by Steven Han.
// Use of this file is governed by the GNU General Public License.
// See the files COPYING and COPYRIGHT for details.
//
//----------------------------------------------------------------------------------------
//
// CueBidConvention.cpp
//
#include "stdafx.h"
#include "EasyB.h"
#include "EasyBdoc.h"
#include "PlayerStatusDialog.h"
#include "CueBidConvention.h"
//
//==================================================================
//
//
BOOL CCueBidConvention::ApplyTest(const CPlayer& player,
const CConventionSet& conventions,
CHandHoldings& hand,
CCardLocation& cardLocation,
CGuessedHandHoldings** ppGuessedHands,
CBidEngine& bidState,
CPlayerStatusDialog& status)
{
// basic test
// if (!pCurrConvSet->IsConventionEnabled(tidCueBids))
// return FALSE;
// see if another convention is active
if (CheckForOtherConventions(bidState))
return FALSE;
//
if (TryCueBid(hand, bidState, status))
return TRUE;
//
if (RespondToConvention(player, conventions, hand, cardLocation, ppGuessedHands, bidState, status))
return TRUE;
//
if (HandleConventionResponse(player, conventions, hand, cardLocation, ppGuessedHands, bidState, status))
return TRUE;
//
return FALSE;
}
//
//---------------------------------------------------------------
//
// TryCueBid()
//
BOOL CCueBidConvention::TryCueBid(CHandHoldings& hand, CBidEngine& bidState, CPlayerStatusDialog& status)
{
// check basic requirements
if (bidState.m_nAgreedSuit == NONE)
return FALSE;
// don't make a cue bid if we're already done with it
int nStatus = bidState.GetConventionStatus(this);
if (nStatus != CONV_INACTIVE)
return FALSE;
// get adjusted point count as declarer
bidState.fAdjPts = hand.RevalueHand(REVALUE_DECLARER, bidState.m_nAgreedSuit, TRUE);
bidState.m_fMinTPPoints = bidState.fAdjPts + bidState.m_fPartnersMin;
bidState.m_fMaxTPPoints = bidState.fAdjPts + bidState.m_fPartnersMax;
bidState.m_fMinTPCPoints = bidState.fCardPts + bidState.m_fPartnersMin;
bidState.m_fMaxTPCPoints = bidState.fCardPts + bidState.m_fPartnersMax;
//
// try a cue bid only if we have an interest in slam
//
if (bidState.m_fMinTPPoints < 30)
return FALSE;
// also, we shouldn't use cue bid if we have all four aces
if (bidState.numAces == 4)
return FALSE;
// or if we're already at a slam level
if (bidState.nPartnersBidLevel >= 6)
return FALSE;
int nLastBid = pDOC->GetLastValidBid();
if (nLastBid >= bidState.GetGameBid(BID_SUIT(nLastBid)))
return FALSE;
// special test -- dont' cue bid if partner just raised a suit that we
// shifted to artificially
if ((bidState.nPartnersSuit == bidState.nPreviousSuit) &&
( (ISSUIT(bidState.m_nAgreedSuit) && (bidState.nPreviousSuit != bidState.m_nAgreedSuit)) ||
(ISSUIT(bidState.m_nIntendedSuit) && (bidState.nPreviousSuit != bidState.m_nIntendedSuit)) ) )
return FALSE;
//
// see what stage we're at
//
if (nStatus == CONV_INACTIVE)
{
//
// showing first round controls
//
// bidState.SetConventionStatus(this, CONV_INVOKED_ROUND1);
// find cheapest ace
int nBid;
int nAgreedSuit = bidState.m_nAgreedSuit;
int nSuit = GetCheapestAce(hand, nAgreedSuit);
//
if ((nSuit != bidState.m_nAgreedSuit) && (nSuit != bidState.nPartnersSuit))
{
// found a suit to cue bid
// the bid must be at a level that commits the partnership to game
// i.e., for a major, it must be > 3 of the suit; for a minor, > 4
nBid = bidState.GetCheapestShiftBid(nSuit);
int nBidLevel = BID_LEVEL(nBid);
// see if the bid is too high to qualify as a cue bid
if ( (ISMAJOR(nAgreedSuit) && (nBidLevel >= 5)) ||
(ISMINOR(nAgreedSuit) && (nBidLevel >= 6)) )
return FALSE;
// else if it's too low, adjust it upwards
if ( (ISMAJOR(nAgreedSuit) && (nBid < MAKEBID(nAgreedSuit,3))) ||
(ISMINOR(nAgreedSuit) && (nBid < MAKEBID(nAgreedSuit,4))) )
nBid += 5;
// alternatively, see if the bid is too high
if (nBid > bidState.GetGameBid(nAgreedSuit))
return FALSE;
status << "CUET10! With " & bidState.m_fMinTPPoints &
"+ pts and possible slam aspirations, make a cue bid, showing the cheapest ace (" &
STS(nSuit) & ") with a bid of " & BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_INVOKED_ROUND1);
return TRUE;
}
else
{
// either we don't have any aces, or the ace is in the trump suit
// either way, we can't make a cue bid with this holding
return FALSE;
}
}
else if (nStatus == CONV_INVOKED_ROUND1)
{
//
// showing second round controls, necesary if we want to proceed to a grand slam
//
bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2);
// find cheapest king or void suit
int nSuit = GetCheapestKingOrVoid(hand, bidState.m_nAgreedSuit);
int nPartnersBid = bidState.nPartnersBid;
//
if (nSuit != bidState.m_nAgreedSuit)
{
// found a suit to cue bid
int nBid = bidState.GetCheapestShiftBid(nSuit);
status << "CUET20! Make a second-round cue bid, showing the cheapest " &
((hand.GetSuitLength(nSuit) == 0)? "void suit" : "king") &
" (in " & STS(nSuit) & ") with a bid of " & BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2);
return TRUE;
}
else
{
// either we don't have any second-round control to show,
// so stop cue bidding and return to the trump suit
int nBid = bidState.GetCheapestShiftBid(bidState.m_nAgreedSuit);
status << "CUET24! With no second-round controls to cue bid, we have to return to the trump suit at a bid of " &
BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2);
return TRUE;
}
}
else if (nStatus == CONV_INVOKED_ROUND2)
{
// both we and partner have shown first and second-round controls, so
// it;s time to put up or shut up
}
else
{
// error!
AfxMessageBox("Error while attempting cue bid!");
bidState.SetConventionStatus(this, CONV_ERROR);
}
//
return TRUE;
}
//
//---------------------------------------------------------------
//
// RespondToConvention()
//
BOOL CCueBidConvention::RespondToConvention(const CPlayer& player,
const CConventionSet& conventions,
CHandHoldings& hand,
CCardLocation& cardLocation,
CGuessedHandHoldings** ppGuessedHands,
CBidEngine& bidState,
CPlayerStatusDialog& status)
{
// first see if another convention is active
if (bidState.GetActiveConvention() &&
(bidState.GetActiveConvention() != this))
return FALSE;
// basic test -- see if we had agreed on a suit last time
if (bidState.m_nAgreedSuit == NONE)
return FALSE;
// get status
int nStatus = bidState.GetConventionStatus(this);
//
int nPartnersBid = bidState.nPartnersBid;
int nPartnersBidLevel = bidState.nPartnersBidLevel;
int nPartnersSuit = bidState.nPartnersSuit;
int nPartnersPrevSuit = bidState.nPartnersPrevSuit;
int nAgreedSuit = bidState.m_nAgreedSuit;
int nSupportLevel = bidState.nPartnersSuitSupport;
int nBid;
// see if partner made a cue bid
// it needs to be a bid that commits the partnership to game,
// after a suit has been agreed upon
if ((nAgreedSuit != NONE) && (nPartnersSuit != NOTRUMP) && (nPartnersSuit != nAgreedSuit) &&
((nPartnersBid > MAKEBID(nAgreedSuit,3)) && (nPartnersBid < bidState.GetGameBid(nAgreedSuit))))
{
// met the requirements
status << "CUR0! Partner made a cue bid of " & BTS(nPartnersBid) &
", hinting at slam prospects.\n";
}
else
{
// this is not a cue bid
return FALSE;
}
//
// respond to a cue bid only if we have an interest in slam
//
// only qualify if we have 30+ team points, _OR_
// strong trump support and 28+ poitns
//
if (bidState.m_fMinTPPoints >= 30)
{
// 30+ team points
status << "2CUR1! And since we have " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
"+ points in the partnership, we want to respond favorably.\n";
}
else if ((nSupportLevel >= SS_GOOD_SUPPORT) &&
(bidState.m_fMinTPPoints >= 28))
{
// good support (4 good or 5 moderate cards)
status << "2CUR2! And since we have " & bidState.SLTS(nPartnersSuit) &
" trump support, " &
((bidState.m_fMinTPPoints >= 30)? " as well as " : " albeit only with ") &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, we want to respond favorably.\n";
}
else
{
// insufficient strength for slam -- correct back to the agreed suit
nBid = bidState.GetCheapestShiftBid(nAgreedSuit);
status << "CUR4! But we don't have the points (only " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" pts in the partnership) or the excellent trump support needed for a marginal slam, so we decline by returning to the agreed suit at a bid of " &
BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
//
// else we're playing along -- find the cheapest response
//
if (nStatus == CONV_INACTIVE)
{
// first invocation -- find the cheapest Ace
int nSuit = GetCheapestAce(hand, nPartnersSuit, bidState.m_nAgreedSuit);
// found a suit with an ace?
if ((nSuit != nPartnersSuit) && (nSuit != nAgreedSuit))
{
// found a suit to cue bid
nBid = bidState.GetCheapestShiftBid(nSuit);
status << "CUR20! Respond to partner's cue bid, showing our cheapest ace (" &
STS(nSuit) & ") with a bid of " & BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_RESPONDED_ROUND1);
return TRUE;
}
else
{
// found no ace, or else it's in the trump suit, so either way
// just sign off at the agreed suit
nBid = bidState.GetCheapestShiftBid(nAgreedSuit);
if (hand.SuitHasCard(nSuit, ACE))
status << "CUR22! But our only Ace is in the trump suit of " &
STSS(nAgreedSuit) & ", so sign off at a bid of " & BTS(nBid) & ".\n";
else
status << "CUR24! We have no other Aces to offer, so sign off with the agreed " &
STSS(nAgreedSuit) & " suit at a bid of " & BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
}
else if (nStatus == CONV_RESPONDED_ROUND1)
{
// second invocation -- find cheapest King or void
// first invocation -- find teh cheapest Ace
int nSuit = GetCheapestKingOrVoid(hand, nPartnersSuit, bidState.m_nAgreedSuit);
// found an appropriate suit?
if ((nSuit != nPartnersSuit) && (nSuit != nAgreedSuit))
{
// found a suit to cue bid
nBid = bidState.GetCheapestShiftBid(nSuit);
status << "CUR30! Respond to partner's cue bid, showing our cheapest " &
((hand.GetSuitLength(nSuit) > 0)? "King" : "void suit") &
" (in " & STS(nSuit) & ") with a bid of " & BTS(nBid) & ".\n";
bidState.SetBid(nBid);
// bidState.SetConventionStatus(this, CONV_RESPONDED_ROUND2);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
else
{
// found no king or void, or else found a king in the trump suit,
// so either way, just sign off at the agreed suit
nBid = bidState.GetCheapestShiftBid(nAgreedSuit);
if (hand.SuitHasCard(nSuit, KING))
status << "CUR32! But our only Ace is in the trump suit of " &
STSS(nAgreedSuit) & ", so sign off at a bid of " & BTS(nBid) & ".\n";
else
status << "CUR34 We have no other Kings or void suits to offer, so sign off with the agreed " &
STSS(nAgreedSuit) & " suit at a bid of " & BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
}
else
{
// error!
bidState.SetConventionStatus(this, CONV_ERROR);
return FALSE;
}
}
//
//---------------------------------------------------------------
//
// HandleConventionResponse()
//
BOOL CCueBidConvention::HandleConventionResponse(const CPlayer& player,
const CConventionSet& conventions,
CHandHoldings& hand,
CCardLocation& cardLocation,
CGuessedHandHoldings** ppGuessedHands,
CBidEngine& bidState,
CPlayerStatusDialog& status)
{
// check state
int nStatus = bidState.GetConventionStatus(this);
if (nStatus <= 0)
return FALSE;
//
int nPartnersBid = bidState.nPartnersBid;
int nPartnersBidLevel = bidState.nPartnersBidLevel;
int nPartnersSuit = bidState.nPartnersSuit;
int nPreviousBid = bidState.nPreviousBid;
int nAgreedSuit = bidState.m_nAgreedSuit;
int nBid;
//
// first check if partner returned to the trump suit, regardless of
// which cue bidding round this is
//
if ( ((nStatus == CONV_INVOKED_ROUND1) || (nStatus == CONV_INVOKED_ROUND2)) &&
(nPartnersSuit == nAgreedSuit) )
{
// first check for a strange response
if ((nPartnersBid == BID_DOUBLE) || (nPartnersBid == BID_REDOUBLE))
{
// we don't understand partner's bid
return CConvention::HandleConventionResponse(player, conventions, hand, cardLocation, ppGuessedHands, bidState, status);
}
// first check for a direct raise to slam by partner in response to our
// cue bid(unlikely, but hey...)
if (nPartnersBidLevel >= 6)
{
status << "HRCB0! In response to our cue bid, partner returned to the agreed " & STSS(nAgreedSuit) &
" trump suit with a slam bid at " & BTS(nPartnersBid) & ".\n";
// raise to a grand slam if possible
if ((nPartnersBidLevel == 6) && (bidState.m_fMinTPPoints >= 37))
{
nBid = MAKEBID(nAgreedSuit,7);
status << "HRCB1! And with " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, go ahead and raise to " &
BTS(nBid) & ".\n";
}
else
{
// sign off on the slam
nBid = BID_PASS;
status << "HRCB2! And with " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, sign off on the slam bid and pass.\n";
}
//
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
//
// otherwise partner returned to the agreed suit below slam,
// a discouraging sign
//
status << "HRCB5! Partner returned to the agreed " & STSS(nAgreedSuit) &
" trump suit in response to our cue bid of " & BTS(nPreviousBid) &
", which is a discouraging sign.\n";
// pass with < 33 team points
if (bidState.m_fMinTPPoints < 33)
{
//
nBid = BID_PASS;
status << "HRCB6! And with only " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, we have to forget about slam and pass.\n" &
BTS(nBid) & ".\n";
}
else if (bidState.m_fMinTPPoints < 37)
{
// with 33-36 pts, bid small slam anyway
nBid = MAKEBID(nAgreedSuit, 6);
status << "HRCB7! But with " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, go ahead and bid a small slam anyway at " &
BTS(nBid) & ".\n";
}
else
{
// with 33-37 pts, bid a grand slam anyway
nBid = MAKEBID(nAgreedSuit, 7);
status << "HRCB8! But with " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, go ahead and bid a grand slam anyway at " &
BTS(nBid) & ".\n";
}
//
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
//
//-----------------------------------------------------------------
//
// else partner made a responding cue bid, an encouraging sign
// now see what stage we're at
//
if (nStatus == CONV_INVOKED_ROUND1)
{
// first check for a strange response
if ((nPartnersBid == BID_DOUBLE) || (nPartnersBid == BID_REDOUBLE))
{
// we don't understand partner's bid
return CConvention::HandleConventionResponse(player, conventions, hand, cardLocation, ppGuessedHands, bidState, status);
}
//
status << "HRCB40! Partner responded with a cue bid of " & BTS(nPartnersBid) &
", showing an Ace in " & STS(nPartnersSuit) & ".\n";
//
// see if we want to proceed to a second round of cue bidding
// we need 36+ pts and controls in all four suits
//
BOOL bAllFourControls;
if ((bidState.numAces + 1) == 4)
{
status << "HRCB42! And with partner's " & STSS(nPartnersSuit) &
", we have all four Aces for full first-round control.\n";
bAllFourControls = TRUE;
}
else
{
status << "HRCB43! But even with partner's " & STSS(nPartnersSuit) &
", it's not clear we have all four Aces for full first-round control.\n";
bAllFourControls = FALSE;
}
//
if ((bidState.m_fMinTPPoints < PTS_SLAM) || (!bAllFourControls))
{
// gotta stop below slam
nBid = bidState.GetCheapestShiftBid(nAgreedSuit);
status << "HRCB46! With only " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership" &
((bAllFourControls)? "," : "and without clear first round controls,") &
" we can't afford to bid slam, so settle for a contract of " &
BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
// else we have >= 33 pts and all four controls
else if (bidState.m_fMinTPPoints < 36)
{
// can only make a small slam
nBid = MAKEBID(nAgreedSuit, 6);
status << "HRCB46! But with only " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, we have to stop at a small with a contract of " &
BTS(nBid) & ".\n";
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
//
// at this point, we have 36+ points, so trigger another round of cue bidding
// find cheapest king or void suit
//
int nSuit = GetCheapestKingOrVoid(hand, bidState.m_nAgreedSuit);
if (nSuit != nAgreedSuit)
{
// found a suit to cue bid for second round
nBid = bidState.GetCheapestShiftBid(nSuit);
status << "HRCB60! Make a second-round cue bid, showing the cheapest " &
((hand.GetSuitLength(nSuit) == 0)? "void suit" : "king") &
" (in " & STS(nSuit) & ") with a bid of " & BTS(nBid) & ".\n";
}
else
{
// either we don't have any second-round control to show, or the
// second round card is in the trump
// so stop cue bidding and return to the trump suit at a small slam
nBid = MAKEBID(nAgreedSuit, 6);
status << "HRCB80! With no second-round controls to cue bid, we have to return to the trump suit with a small slam at " &
BTS(nBid) & ".\n";
}
//
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
else if (nStatus == CONV_INVOKED_ROUND2)
{
// first check for a strange response
if ((nPartnersBid == BID_DOUBLE) || (nPartnersBid == BID_REDOUBLE))
{
// we don't understand partner's bid
return CConvention::HandleConventionResponse(player, conventions, hand, cardLocation, ppGuessedHands, bidState, status);
}
//
// both we and partner have shown first and second-round controls,
// so now it's time to put up or shut up
//
// if we like the controls and have enough points, bid grand slam;
// else bid a small slam or game
//
//
// see if we want to proceed to a second round of cue bidding
// we need 36+ pts and controls in all four suits
//
BOOL bAllFourSecondRoundControls;
if ((bidState.numKings + 1) == 4)
{
status << "HRCBS10! And with partner's " & STSS(nPartnersBid) &
" bid showing a King or void, in " & STS(nPartnersSuit) &
", we have scond-round control of all four suits.\n";
bAllFourSecondRoundControls = TRUE;
}
else
{
status << "HRCBS12! But even with partner's " & STSS(nPartnersBid) &
", it's not clear we have all full second-round control.\n";
bAllFourSecondRoundControls = FALSE;
}
//
if ((bidState.m_fMinTPPoints < 32) || (!bAllFourSecondRoundControls))
{
// gotta stop below slam
nBid = bidState.GetCheapestShiftBid(nAgreedSuit);
status << "HRCBS20! With only " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership " &
((bAllFourSecondRoundControls)? "," : "and without clear second round controls,") &
" we can't afford to bid slam, so settle for a contract of " &
BTS(nBid) & ".\n";
}
// else we have >= 32 pts and all four controls
else if (bidState.m_fMinTPPoints < 36)
{
// can only make a small slam
nBid = MAKEBID(nAgreedSuit, 6);
status << "HRCBS24! But with only " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership, we have to stop at a small with a contract of " &
BTS(nBid) & ".\n";
}
else
{
//
// else we have 36+ points, so go ahead and bid a grand slam
//
int nBid = MAKEBID(nAgreedSuit, 7);
status << "HRCBS40! With a total of " &
bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
" points in the partnership and full first and second-round controls, go head and bid a grand slam at " &
BTS(nBid) & ".\n";
}
//
bidState.SetBid(nBid);
bidState.SetConventionStatus(this, CONV_FINISHED);
return TRUE;
}
else
{
// N/A
return FALSE;
}
//
return TRUE;
}
//
//==================================================================
//
// Misc utility functions
//
//
// GetCheapestAce()
//
// returns the next cheapest suit with an Ace
// used for cue bidding
//
int CCueBidConvention::GetCheapestAce(CHandHoldings& hand, int nBaseSuit, int nSecondSuit)
{
int i;
//
if (nBaseSuit < CLUBS)
return NONE;
//
int nSuit;
if (nBaseSuit == NOTRUMP)
nSuit = CLUBS;
else
nSuit = GetNextSuit(nBaseSuit);
for(i=0;i<4;i++)
{
if (hand.SuitHasCard(nSuit, ACE) && (nSuit != nSecondSuit))
break;
nSuit = GetNextSuit(nSuit);
}
//
if (i < 4)
return nSuit;
else
return nBaseSuit;
}
//
// GetCheapestKingOrVoid()
//
// returns the next cheapest suit with a king or void
//
int CCueBidConvention::GetCheapestKingOrVoid(CHandHoldings& hand, int nBaseSuit, int nSecondSuit)
{
int i;
//
if (nBaseSuit < CLUBS)
return NONE;
//
int nSuit;
if (nBaseSuit == NOTRUMP)
nSuit = CLUBS;
else
nSuit = GetNextSuit(nBaseSuit);
for(i=0;i<4;i++)
{
// suit should be void or else have a king
if ( ((hand.GetSuitLength(nSuit) == 0) || hand.SuitHasCard(nSuit, KING)) &&
(nSuit != nSecondSuit) )
break;
nSuit = GetNextSuit(nSuit);
}
//
if (i < 4)
return nSuit;
else
return nBaseSuit;
}
//
//==================================================================
// construction & destruction
//
CCueBidConvention::CCueBidConvention()
{
// from ConvCodes.h
m_nID = tidCueBids;
}
CCueBidConvention::~CCueBidConvention()
{
}