// //--------------------------------------------------------------- // // MakeOpeningBid() // // make initial bid // int CBidEngine::MakeOpeningBid() { CPlayerStatusDialog& status = *m_pStatusDlg; // status << "2Opening bid for team.\n"; // //-------------------------------------------------------- // // First check to see if we can open using a convention // e.g., weak 2, stong 2, preemptive 3/4, etc. // if (pCurrConvSet->ApplyConventionTests(*m_pPlayer, *m_pHand, *m_pCardLocation, m_ppGuessedHands, *this, *m_pStatusDlg)) { return ValidateBid(m_nBid); } // //-------------------------------------------------------- // // see if we can open No Trumps // int NTMin[3], NTMax[3]; // NTMin[0] = pCurrConvSet->GetValue(tn1NTRangeMinPts); NTMax[0] = pCurrConvSet->GetValue(tn1NTRangeMaxPts); NTMin[1] = pCurrConvSet->GetValue(tn2NTRangeMinPts); NTMax[1] = pCurrConvSet->GetValue(tn2NTRangeMaxPts); NTMin[2] = pCurrConvSet->GetValue(tn3NTRangeMinPts); NTMax[2] = pCurrConvSet->GetValue(tn3NTRangeMaxPts); // if ((bBalanced) && (fCardPts >= OPEN_PTS(NTMin[0]))) { // status << "A00! Have " & fCardPts & " HCP's with a balanced hand.\n"; // but if we have a good 5-card major, open it in a suit // but not if we have to overcall to do so BOOL bNeedToOvercall = FALSE; if ( ((nLHOBid > BID_PASS) || (nRHOBid > BID_PASS)) && (nPartnersBid <= BID_PASS)) bNeedToOvercall = TRUE; // if (IsSuitOpenable(HEARTS) && !bNeedToOvercall) { status << "A02! But with an openable " & numCardsInSuit[HEARTS] & "-card Heart suit, prefer to open in the major instead of in No Trump.\n"; goto escape1; } if (IsSuitOpenable(SPADES) && !bNeedToOvercall) { status << "A04! But with an openable " & numCardsInSuit[SPADES] & "-card Spade suit, prefer to open in the major instead of in No Trump.\n"; goto escape1; } // check range for 1NT // NCR-285 Need stopper if opponents have bid!!! BOOL bHaveOppsStopped = TRUE; if ((nRHOBid != BID_PASS) && ISSUIT(nRHOSuit)) bHaveOppsStopped = m_pHand->IsSuitStopped(nRHOSuit); // NCR-285 consider if their suit is stopped else if ((nLHOBid != BID_PASS) && ISSUIT(nLHOSuit)) bHaveOppsStopped = m_pHand->IsSuitStopped(nLHOSuit); // NCR-285 ditto if ((fCardPts >= OPEN_PTS(NTMin[0])) && (fCardPts <= NTMax[0]) && bHaveOppsStopped) // NCR-285 added test { // NCR-18 Check if RHO bid NT and double if(nRHOBid == BID_1NT){ m_nBid = BID_DOUBLE; // NCR-337 Problem here. This is not a Takeout double??? status << "A07! This meet the rqmts for the 1NT opening range (" & NTMin[0] & "-" & NTMax[0] & "), but RHO has bid 1NT, so Double.\n"; }else { // open 1NT m_nBid = BID_1NT; status << "A08! This meet the rqmts for the 1NT opening range (" & NTMin[0] & "-" & NTMax[0] & "), so bid 1NT.\n"; } return ValidateBid(m_nBid); } else if ((fCardPts > OPEN_PTS(NTMax[0])) && (fCardPts < NTMin[1])) { // in-between 1 & 2 situation; bid interim suit m_nNextIntendedBid = NIB_JUMP_NT; if (numOpenableSuits > 0) { // bid 1 of lowest openable suit m_nBid = GetLowestOpenableBid(SUITS_ANY,OT_OPENER,1); // NCR-335 Don't bid 4 card major with 5CardMajor convention if (ISMAJOR(BID_SUIT(m_nBid)) && pCurrConvSet->IsConventionEnabled(tid5CardMajors) && (numCardsInSuit[BID_SUIT(m_nBid)] < 5) ) { // Use Diamonds if 4, else clubs (have balanced hand here) Suit bidThis = numCardsInSuit[DIAMONDS] >= 4 ? DIAMONDS : CLUBS; m_nBid = MAKEBID(bidThis, 1); // NCR-335 use minor } status << "A10! This exceeds the max pts for a 1NT opening (" & NTMax[0] & "), but is less than min pts for 2NT (" & NTMin[1] & "). So bid the lowest openable suit of " & BTS(m_nBid) & " for now, then try for a jump shift to 2NT later.\n"; } else { // go ahead and bid the preferred suit if (!pCurrConvSet->IsConventionEnabled(tid5CardMajors) ) { m_nBid = MAKEBID(nPrefSuit,1); } else { m_nBid = BID_1C; } status << "A14! This exceeds the max pts for a 1NT opening (" & NTMax[0] & "), but is less than min pts for 2NT (" & NTMin[1] & " and we have no good openable suit, so just bid " & BTS(m_nBid) & " for now.\n"; } return ValidateBid(m_nBid); } // NCR can't use 2NT if using unusual NT convention else if ((fCardPts >= OPEN_PTS(NTMin[1])) && (fCardPts <= NTMax[1]) // && !pCurrConvSet->IsConventionEnabled(tidUnusualNT) // NCR not relevant for Opening??? // NCR test that hand does NOT have a worthless doubleton && ((m_pHand->GetNumDoubletons() == 0) // OK if no doubletons || (m_pHand->GetNumDoubletons() >= 1) && !m_pHand->HasWorthlessDoubleton()) //or if its not worthless ) { // open 2NT m_nBid = BID_2NT; status << "A20! This meets the rqmts for a 2NT opening (" & NTMin[1] & "-" & NTMax[1] & "), so bid 2NT.\n"; return ValidateBid(m_nBid); } else if ((fCardPts >= OPEN_PTS(NTMax[1])) && (NTMin[2] < 0)) // NCR ??? see next else if { // > pts for 2NT, but 3NT opening not allowed NCR what does not allowed mean??? // so bid 2C m_nBid = BID_2C; status << "A30! This exceeds the max pts for a 2NT opening (" & NTMax[1] & "), but a 3NT opening has been disallowed, so open with " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } else if ((fCardPts > OPEN_PTS(NTMax[1])) && (fCardPts < NTMin[2])) { // in-between 2 & 3 situation; bid 2 of interim suit // and bid NT later m_nNextIntendedBid = NIB_NT; if (numOpenableSuits > 0) { // bid 1 of lowest openable suit m_nBid = GetLowestOpenableBid(SUITS_ANY,OT_OPENER,1); status << "A40! This exceeds the max pts for a 2NT opening (" & NTMax[1] & "), but is less than min pts for 3NT (" & NTMin[2] & "). So bid the lowest openable suit of " & BTS(m_nBid) & " for now, then jump shift to NT later.\n"; } else { // no good openable suits; just bid preferred suit m_nBid = MAKEBID(nPrefSuit,1);; status << "A42! This exceeds the max pts for a 2NT opening (" & NTMax[1] & "), but is less than min pts for 3NT (" & NTMin[2] & "), and have no good openable suit, so bid " & BTS(m_nBid) & " for now.\n"; } return ValidateBid(m_nBid); } else if ((fCardPts >= OPEN_PTS(NTMin[2])) && (fCardPts <= NTMax[2]) // NCR test that hand does NOT have a worthless doubleton && ((m_pHand->GetNumDoubletons() == 0) // OK if no doubletons || (m_pHand->GetNumDoubletons() >= 1) && !m_pHand->HasWorthlessDoubleton()) //or if its not worthless ) { // open 3NT m_nBid = BID_3NT; status << "A50! Bid 3NT.\n"; return ValidateBid(m_nBid); } /* NCR remove falling into a 3NT bid else // if(!pCurrConvSet->IsConventionEnabled(tidUnusualNT)) // NCR added Unusual test??? { // > 3NT point range? unusual, but open 3NT for now m_nBid = BID_3NT; status << "A60! bid 3NT with balanced hand and " & fCardPts & " points.\n"; // NCR return ValidateBid(m_nBid); } */ } // end balanced hand with > min pts escape1: // //------------------------------------------------------------------- // // See if we can open at the 1-level // // open at the 1-level if we have: // 1: 14+ points in high cards // 2: 13+ HCPs with 2 Quick Tricks // 3: 12+ HCPs with 2 QTs and a rebiddable suit // 4: 12+ HCPs with 2 QTs and a 5-card suit // 5: 12+ HCPs with balanced dist (weak NT mode only) // 6: 10+ HCPs opening in 3rd or 4th seat and a good suit NCR ??? // 7: 15+ Total points with 2 QTs // 8: 14+ Total points with 2 QTs and a rebiddable suit // 9: 13+ Total points with 2 QTs and a rebiddable suit of 6+ cards // // we can only open if the opponents haven't opened yet // if they have, the COvercallsCovention object should have looked into // a posssible overcall. if ((nLHOBid > BID_PASS) || (nRHOBid > BID_PASS)) { status << "B00! We cannot overcall and the hand is not appropriate for any other bid, so pass.\n"; m_nBid = BID_PASS; return ValidateBid(m_nBid); } // the suit to open us usually the best suit nSuit = GetBestOpeningSuit(); // case 1: 14+ points in high cards if (fCardPts >= OPEN_PTS(14)) { m_nBid = MAKEBID(nSuit,1); status << "E01! Have " & fCardPts & " points in high cards, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // case 2: 13+ HCP's && 2 QT's if ((fCardPts >= OPEN_PTS(13)) && (numQuickTricks >= 2)) { m_nBid = MAKEBID(nSuit,1); status << "E02! Have " & fCardPts & " points in high cards and " & numQuickTricks & " quick tricks, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } // case 3: 12+ HCP's, 2 QT's, & a rebiddable suit // NCR-680 reduce QTs if ((fCardPts >= OPEN_PTS(12)) && (numQuickTricks >= PT_COUNT(2)) && (numRebiddableSuits > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E03! Have " & fCardPts & " points in high cards, " & numQuickTricks & " quick tricks, and a rebiddable suit in " & STS(nSuit) & ", so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } // case 4: 12+ HCP's, 2 QT's, & a 5-card suit if ((fCardPts >= OPEN_PTS(12)) && (numQuickTricks >= 2) && (m_pHand->GetNumSuitsOfAtLeast(5) > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E04! Have " & fCardPts & " points in high cards, " & numQuickTricks & " quick tricks, and a " & numCardsInSuit[nSuit] & "-card suit, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // case 5: 12+ HCP's & a balanced dist in Weak NTs if ((fCardPts >= OPEN_PTS(12)) && (bBalanced) && (pCurrConvSet->GetValue(tn1NTRange) == 0)) { m_nBid = BID_1NT; status << "E05! Have " & fCardPts & " points in high cards, a balanced hand, " & "and playing Weak No Trumps, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // case 6: 10+ HCPs opening in 3rd or 4th seat & a good suit // if ((fCardPts >= OPEN_PTS(10)) if ((fCardPts >= 10) // NCR-206 Hard 10 and > 4 cards && (((nBiddingOrder == 2) && (numCardsInSuit[nSuit] > 4)) // NCR require Having spades to open light in 4th || ((nBiddingOrder == 3) & (numCardsInSuit[SPADES] > 3)) && (nSuit == SPADES)) && (numOpenableSuits > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E07! Have " & fCardPts & " points in high cards in " & ((nBiddingOrder == 2)? "3rd" : "4th") & " position and a " & SSTS(nSuit) & " " & STSS(nSuit) & " suit, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // case 7: 15+ Total points and 10 HCPs, with 2 QTs if ((fPts >= OPEN_PTS(15)) && (fCardPts >= OPEN_PTS(10)) && (numQuickTricks >= 2)) { m_nBid = MAKEBID(nSuit,1); status << "E08! Have " & fCardPts & "/" & fPts & " total points with " & numQuickTricks & " QT's, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // // case 8: 14+ Total points with 10+ HCPs, 2 QTs // and a rebiddable suit if ((fPts >= OPEN_PTS(14)) && (fCardPts >= OPEN_PTS(10)) && (numQuickTricks >= 2) && (numRebiddableSuits > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E09! Have " & fCardPts & "/" & fPts & " total points with " & numQuickTricks & " QT's and a rebiddable suit, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } // // case 9: 13+ Total points with 10+ HCPs, 2 QTs and a // rebiddable suit of 6+ cards if ((fPts >= OPEN_PTS(13)) && (fCardPts >= OPEN_PTS(10)) && (numQuickTricks >= 2) && (numRebiddableSuits > 0) && (numPrefSuitCards >= 6) && (nSuitStrength[nPrefSuit] > SS_OPENABLE)) { m_nBid = MAKEBID(nSuit,1); status << "E10! Have " & fCardPts & "/" & fPts & " total points with " & numQuickTricks & " QT's and a " & numCardsInSuit[nSuit] & "-card rebiddable suit, so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // //--------------------------------------------------------- // // now test for optional 1-level openings // int nAllowed1Opens = pCurrConvSet->GetValue(tnAllowable1Openings); // // option 1: 11+ HCPs with 2 QTs, a rebiddable suit, & // length in both majors // if ((nAllowed1Opens & OB_11_HCPS_RBS_LM) && (fCardPts >= OPEN_PTS(11)) && (numQuickTricks >= 2) && (numRebiddableSuits > 0) && (numCardsInSuit[HEARTS] >= 4) && (numCardsInSuit[SPADES] >= 4)) { m_nBid = MAKEBID(nSuit,1); status << "E21! Have " & fCardPts & " points in high cards, " & numQuickTricks & " quick tricks, a rebiddable suit, and length in both majors " & "(optional opening condition #1), so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // // option 2: 11+ HCPs with 2 QTs and a 6-card suit // if ((nAllowed1Opens & OB_11_HCPS_6CS) && (fCardPts >= OPEN_PTS(11)) && (numQuickTricks >= 2) && (m_pHand->GetNumSuitsOfAtLeast(6) > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E22! Have " & fCardPts & " points in high cards with " & numQuickTricks & " QT's and a " & numCardsInSuit[nSuit] & "-card suit (optional opening condition #2), so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } // // option 3: 14+ Total points with 10 HCPs, 2 QTs, and a // good suit // if ((nAllowed1Opens & OB_14_TCPS_GS) && (fPts >= OPEN_PTS(14)) && (fCardPts >= OPEN_PTS(10)) && (numQuickTricks >= 2) && (numSolidSuits > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E23! Have " & fCardPts & "/" & fPts & "total points with " & numQuickTricks & " QT's and a " & SSTS(nSuit) & " " & STSS(nSuit) & " suit (optional opening condition #3), so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } // // option 4: 14+ Total points with 10 HCPs, 2 QTs, and a // long suit (6+ cards) // if ((nAllowed1Opens & OB_14_TCPS_LS) && (fPts >= OPEN_PTS(14)) && (fCardPts >= OPEN_PTS(10)) && (numQuickTricks >= 2) && (m_pHand->GetNumSuitsOfAtLeast(6) > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E24! Have " & fCardPts & "/" & fPts & " total points with " & numQuickTricks & " QT's and a " & numCardsInSuit[nSuit] &"-card " & STSS(nSuit) & " suit (optional opening condition #4), so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } // // option 5: 13+ Total points with 2 QTs, 10 HCPs, // and a 6-card suit // if ((nAllowed1Opens & OB_13_TCPS_LS) && // NCR-390 Add in distribution points here and below in status msg ((fPts + fDistPts) >= OPEN_PTS(13)) && (fCardPts >= OPEN_PTS(10)) && (numQuickTricks >= 2) && (m_pHand->GetNumSuitsOfAtLeast(6) > 0)) { m_nBid = MAKEBID(nSuit,1); status << "E25! Have " & fCardPts & "/" & (fPts+fDistPts) &" total points with " & numQuickTricks & " QT's and a " & numCardsInSuit[nSuit] & "-card " & STSS(nSuit) & " suit (optional opening condition #5), so bid " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } /* // // special case: 13 pts + 1 for every 0.5 QTs missing if ((fPts > OPEN_PTS(13)) && (numQuickTricks < 2)) { int nRqmt = 13 + (int)(((2.0 - numQuickTricks)*2)); if (fPts >= nRqmt) { m_nBid = MAKEBID(nSuit,1); status << "E27! Have " & fCardPts & "/" & fPts & " total points; shade opening requirement of 2 QT's and make do with " & numQuickTricks & " QT's in light of the high total point count; open " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } } */ // NCR-356 Loosen up a bit here - bid 5 card major if ... if((fCardPts >= OPEN_PTS(13)) && ISMAJOR(nSuit) && (numCardsInSuit[nSuit] >= 5) && pCurrConvSet->IsConventionEnabled(tid5CardMajors) ) { m_nBid = MAKEBID(nSuit,1); status << "E28! Have " & fCardPts & "/" & fPts & " total points; shade opening requirement of 2 QT's and make do with " & numQuickTricks & " QT's; open " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid);; } // end NCR-356 // NCR Is Convenient minor (goes with 5card Majors) appropriate - 13 HCPs and 3 clubs if((fCardPts >= OPEN_PTS(13)) && pCurrConvSet->IsConventionEnabled(tid5CardMajors) && (numCardsInSuit[CLUBS] >= 3)) { m_nBid = BID_1C; if(numCardsInSuit[DIAMONDS] > numCardsInSuit[CLUBS]) // NCR-507 Bid Diamonds if more of them m_nBid = BID_1D; status << "E31! Have " & fCardPts & " points in high cards , so bid a Convenient minor " & BTS(m_nBid) & ".\n"; return ValidateBid(m_nBid); } // //-------------------------------------------------------- // // All attempts at opening failed, so return a PASS // status << "Z00! Hand is insufficient for any opening, so pass.\n"; m_nBid = BID_PASS; return ValidateBid(m_nBid);; }
// //--------------------------------------------------------------- // // 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)))) { //NCR what if suit was previously bid by this player??? // EG: N->1H, S->2C, N->3C, S->3H 3H is NOT a cue bid, it's a response to this player's previous bid // NCR how to test if partner's current bid was in suit previously bid ??? // NCR what about a game bid??? int nSuit = BID_SUIT(nPartnersBid); for(int i=0; i < player.GetNumBidsMade(); i++) { // NCR had to add const to this function def int nSuitBid = pDOC->GetBidByPlayer(player.GetPosition(), i); if(BID_SUIT(nSuitBid) == nSuit) return FALSE; // NCR not cue if partner bid before ??? } // NCR-295 game bid in agreed suit??? if(bidState.IsGameBid(nPartnersBid) && (nSuit == nAgreedSuit) ) // || CheckIfSuitBid(player, BID_SUIT(nPartnersBid))) { return FALSE; //NCR don't treat Game bid as cue bid } // 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; } }
// //=============================================================================== // // TryConvention() // // check if we can use a Michaels Cue Bid here // BOOL CMichaelsCueBidConvention::TryConvention(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { // // the requirements for a Michaels Cue Bid are: // 1: RHO must have opened a suit (not NT) at the 1-level // 2: this must be our first bidding opportunity // 3: need a 2-suited hand; i.e., // - if RHO bid a minor, need 5/5 or 5/(good)4 in the majors // - if RHO bid a major, need 5 in the other major, plus 5 in a minor // the two suits should also be rather comparable // 4: need either 6-11 pts or 17+ pts // (with 12-16 pts, we generally overcall or double for takeout) // 5: if we have 12+ pts and playing takeout doubles, cannot have a // hand suitable for a takeout (???) // test conditions 1, 2, & 4 if ( ((bidState.nRHOBid >= BID_1C) && (bidState.nRHOBid <= BID_1S)) && ( ((bidState.fPts >= OPEN_PTS(6)) && (bidState.fPts <= OPEN_PTS(11))) || ((bidState.fPts >= OPEN_PTS(17))/*&& (bidState.fPts <= 18)*/) ) && (bidState.m_numBidTurns == 0) && (bidState.m_numPartnerBidTurns == 0) ) { // passed } else { return FALSE; } // test condition #3 int nOppSuit = bidState.nRHOSuit; BOOL bEnoughLength = FALSE; // if (ISMINOR(nOppSuit)) { // need 5/5 in the majors, or 5 + good 4 int numHearts = hand.GetNumCardsInSuit(HEARTS); int numSpades = hand.GetNumCardsInSuit(SPADES); if ((hand.GetSuitStrength(HEARTS) < SS_MARGINAL_OPENER) || (hand.GetSuitStrength(SPADES) < SS_MARGINAL_OPENER) || (Abs(hand.GetSuitStrength(HEARTS) - hand.GetSuitStrength(SPADES)) > 1) ) return FALSE; // if ((numHearts >= 5) && (numSpades >= 5)) { bEnoughLength = TRUE; status << "2MCL1! We have at least 5/5 in the majors, so we can make a Michaels cue bid.\n"; } else if ((numHearts >= 5) && (numSpades == 4) && (hand.GetSuitStrength(SPADES) >= SS_STRONG)) { bEnoughLength = TRUE; status << "2MCL2! We have 5/4 in the majors, but the 4 Spades are strong, so we can make a Michaels cue bid.\n"; } else if ((numHearts == 4) && (numSpades >= 5) && (hand.GetSuitStrength(HEARTS) >= SS_STRONG)) { bEnoughLength = TRUE; status << "2MCL3! We have 5/4 in the majors, but the 4 Hearts are strong, so we can make a Michaels cue bid.\n"; } } else { // need 5 in the unbid major, and 5 in a minor int nOtherMajor = (nOppSuit == HEARTS)? SPADES : HEARTS; int numMajors = hand.GetNumCardsInSuit(nOtherMajor); int numClubs = hand.GetNumCardsInSuit(CLUBS); int numDiamonds = hand.GetNumCardsInSuit(CLUBS); // check that the major suit is OK if ((numMajors < 5) || (hand.GetSuitStrength(nOtherMajor) < SS_MARGINAL_OPENER)) return FALSE; // then check the minor & compare the suits if ((numClubs >= 5) && (hand.GetSuitStrength(CLUBS) >= SS_MARGINAL_OPENER) && (Abs(hand.GetSuitStrength(nOtherMajor) - hand.GetSuitStrength(CLUBS)) <= 1) ) { bEnoughLength = TRUE; status << "2MCL5! We have 5+ cards in " & STS(nOtherMajor) & " and 5+ cards in a minor (Clubs), so we can make a Michaels cue bid.\n"; } else if ((numDiamonds >= 5) && (hand.GetSuitStrength(DIAMONDS) >= SS_MARGINAL_OPENER) && (Abs(hand.GetSuitStrength(nOtherMajor) - hand.GetSuitStrength(DIAMONDS)) <= 1) ) { bEnoughLength = TRUE; status << "2MCL5! We have 5+ cards in " & STS(nOtherMajor) & " and 5+ cards in a minor (Diamonds), so we can make a Michaels cue bid.\n"; } } // check condition if (!bEnoughLength) return FALSE; // OK, go ahead and cue-bid the enemy suit int nBid = MAKEBID(nOppSuit, 2); status << "MCL9! With a 2-suited hand, make a Michaels cue bid over RHO's " & STS(nOppSuit) & " with a bid of " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_INVOKED); return TRUE; }
// //========================================================== // // Rebidding as opener after partner responds to a takeout double // BOOL CNegativeDoublesConvention::HandleConventionResponse(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { // there's no code here for now return FALSE; // check status if ((bidState.GetConventionStatus(this) != CONV_INVOKED_ROUND1) && (bidState.GetConventionStatus(this) != CONV_INVOKED_ROUND2)) return FALSE; // // get some info // // int nBid; double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; double fCardPts = bidState.fCardPts; int nPrefSuit = bidState.nPrefSuit; int nPrefSuitStrength = bidState.nPrefSuitStrength; int nPreviousSuit = bidState.nPreviousSuit; BOOL bBalanced = bidState.bBalanced; // int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPartnersSuit = bidState.nPartnersSuit; int nPartnersSuitSupport = bidState.nPartnersSuitSupport; int nPartnersPrevSuit = bidState.nPartnersPrevSuit; int numSupportCards = bidState.numSupportCards; // 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); } // if (bidState.GetConventionStatus(this) == CONV_INVOKED_ROUND1) { // //-------------------------------------------------------- // responding to partner's forced bid // - estimate partner's strength // // // did partner pass? (horror of horrors!) // if (nPartnersBid == BID_PASS) { if (bidState.nLHOBid >= BID_PASS) status << "NGDRb10! After interference from the left-hand opponent, partner passed our takeout.\n"; else status << "NGDRb12! Partner unexpectedly passed our takeout double, which is supposed to be forcing. Bidding will proceed as if the takeout was not made\n"; bidState.SetConventionStatus(this, CONV_FINISHED); return FALSE; } // set team point estimates -- be conservative BOOL bPartnerJumped = FALSE; BOOL bPartnerJumpedToGame = FALSE; int nEnemyBid = pDOC->GetValidBidRecord(0); int nEnemyBidLevel = BID_LEVEL(nEnemyBid); int nEnemySuit = BID_SUIT(nEnemyBid); if (nPartnersBidLevel > (nEnemyBidLevel + 1)) bPartnerJumped = TRUE; if (nPartnersBid == bidState.GetGameBid(nPartnersSuit)) bPartnerJumpedToGame = TRUE; // flag to see if we doubled in preference to an overcall BOOL bWantedToOvercall = FALSE; // if (nPartnersSuit == NOTRUMP) { // if (nPartnersBid == BID_1NT) { // partner has 6-9 HCPs bidState.m_fPartnersMin = 6; bidState.m_fPartnersMax = 9; } else if (nPartnersBid == BID_2NT) { // partner has 10-12 HCPs, maybe more bidState.m_fPartnersMin = 10; bidState.m_fPartnersMax = 12; } else if (nPartnersBid == BID_3NT) { // partner has 13+ HCPs bidState.m_fPartnersMin = 13; bidState.m_fPartnersMax = 40 - fCardPts; status << "NGDRb20! Partner's response of 3NT to our takeout double indicates that the opponent's suit is well stopped.\n"; } else { // partner has 13+ HCPs??? status << "NGDRb21! Partner's response of " & BTS(nPartnersBid) & " to our takeout double is unorthodox; treating it like a 3NT response.\n"; bidState.m_fPartnersMin = 13; bidState.m_fPartnersMax = MIN(22, 40 - fCardPts); } // accept NT if we hold at least a semi-balanced // and we don't have a 6-card major if ( !(ISMAJOR(bidState.nPrefSuit) && (bidState.numPrefSuitCards >= 6)) && (bidState.bSemiBalanced) ) bidState.m_nAgreedSuit = NOTRUMP; // bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; status << "NGDRb29! Partner's response of " & BTS(nPartnersBid) & " to our takeout double indicates " & bidState.m_fPartnersMin & "-" & bidState.m_fPartnersMax & " HCPs, for a total of " & bidState.m_fMinTPCPoints & "-" & bidState.m_fMaxTPCPoints & " / " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership.\n"; } else { // partner bid a suit // see if we really intended to overcall last time if (bidState.GetConventionStatus(&overcallsConvention) == CONV_SUBSUMED) bWantedToOvercall = TRUE; // if (nPartnersSuit == nEnemySuit) { // partner bid the enemy suit, showing 13+ pts. status << "NEGDRb40! Partner has responded in the enemy suit, indicating 13+ pts but no long suits.\n"; bidState.m_fPartnersMin = 13; bidState.m_fPartnersMax = MIN(22, 40 - bidState.fCardPts); bidState.m_bGameForceActive = TRUE; } else if (bPartnerJumpedToGame) { // partner had 13+ pts & a 5-card major status << "NEGDRb41! Partner has jumped to game in " & STS(nPartnersSuit) & ", indicating 13+ pts and a 5+ card suit.\n"; bidState.m_fPartnersMin = 30; bidState.m_fPartnersMax = MIN(22, 40 - bidState.fCardPts); if (!bWantedToOvercall) bidState.m_nAgreedSuit = nPartnersSuit; } else if (bPartnerJumped) { // partner had 10-12 pts status << "NEGDRb42! Partner has made a jump response of " & BTS(nPartnersBid) & ", indicating 10-12 pts and a 4-5 card suit.\n"; bidState.m_fPartnersMin = 10; bidState.m_fPartnersMax = 12; if (!bWantedToOvercall) bidState.m_nAgreedSuit = nPartnersSuit; } else { // partner had <= 9 pts status << "NEGDRb43! Partner has made a minimum response of " & BTS(nPartnersBid) & ", indicating no more than 9 points.\n"; bidState.m_fPartnersMin = 0; bidState.m_fPartnersMax = 9; if (!bWantedToOvercall) bidState.m_nAgreedSuit = nPartnersSuit; } // bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; status << "NGDRb49! The total point count in the partnership is therefore " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts.\n"; } // // see if RHO bid after partner's response -- that mitigates our responsibility // to bid again, unless partner's bid was game forcing // // if (bidState.nRHOBid > BID_PASS) if ((bidState.nRHOBid > BID_PASS) && (bidState.nRHOBid != BID_DOUBLE) && (bidState.nRHOBid != BID_REDOUBLE)) { status << "2NGDRb51! The right-hand opponent has " & ((bidState.nRHOBid == BID_DOUBLE)? "doubled" : "bid") & " after partner's response, interfering with our communication.\n"; } // //--------------------------------------------------------------------- // see if we have an agreed suit // int nBid; if (bidState.m_nAgreedSuit > NONE) { if (bidState.m_nAgreedSuit == NOTRUMP) { // we've agreed to play in NoTrump // see if we can raise partner to a higher NT contract if (bidState.BidNoTrumpAsAppropriate(FALSE,STOPPED_DONTCARE)) { bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // else pass nBid = BID_PASS; status << "NGDRb69! With a total of " & bidState.m_fMinTPCPoints & "-" & bidState.m_fMaxTPCPoints & " HCPs in the partnership, we have insufficient strength to raise partner's " & BTS(nPartnersBid) & " bid, so we have to pass.\n"; bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } else { // we've agreed on a suit, so raise if possible // if partner didn't jump, we may have credited him with // zero pts, so adjust rqmts accordingly // if partner jumped to game && we have < 32 pts, pass if ((bPartnerJumpedToGame) && (bidState.m_fMinTPPoints < 32)) { status << "NGDRb70! Partner jumped to game in his " & bidState.szPSS & " suit, so with a team total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " points, we pass.\n"; bidState.SetBid(BID_PASS); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // raise partner if possible -- bearing in mind that // partner may have a wide range of points // raise a major to game with 23-31 pts and 4 trumps // or with 26-31 pts and 3 trumps // or raise to the 3-level with 20-24 pts and 3 trumps if ( (bidState.RaisePartnersSuit(SUIT_MAJOR,RAISE_TO_4,PTS_MAJOR_GAME-3,31,SUPLEN_4)) || (bidState.RaisePartnersSuit(SUIT_MAJOR,RAISE_TO_4,PTS_MAJOR_GAME,31,SUPLEN_3)) || (bidState.RaisePartnersSuit(SUIT_MAJOR,RAISE_TO_3,PTS_MAJOR_GAME-6,24,SUPLEN_3))) { if (!bPartnerJumped) status << "NGDRb71a! (we can assume partner has some strength in the " & bidState.szPSS & " suit, so we are shading the requirements slightly.\n"; bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); return TRUE; } // raise a minor to game with 28-32 pts and 4 trumps // or with 29-32 pts and 3 trumps // or raise to the 4-level with 26-28 pts and 3 trumps // or raise to the 3-level with 23-25 pts and 3 trumps if ( (bidState.RaisePartnersSuit(SUIT_MINOR,RAISE_TO_5,PTS_MINOR_GAME-1,PTS_SLAM-1,SUPLEN_4)) || (bidState.RaisePartnersSuit(SUIT_MINOR,RAISE_TO_5,PTS_MINOR_GAME,PTS_SLAM-1,SUPLEN_3)) || (bidState.RaisePartnersSuit(SUIT_MINOR,RAISE_TO_4,PTS_MINOR_GAME-3,PTS_MINOR_GAME-1,SUPLEN_3)) || (bidState.RaisePartnersSuit(SUIT_MINOR,RAISE_TO_3,PTS_MINOR_GAME-6,PTS_MINOR_GAME-4,SUPLEN_3)) ) { if (!bPartnerJumped) status << "NGDRb71b! We can assume partner has some strength in the " & bidState.szPSS & " suit, so we can shade the requirements slightly.\n"; bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); return TRUE; } // with 32+ pts, invoke Blackwood if (bidState.m_fMinTPCPoints >= 32) { bidState.InvokeBlackwood(bidState.m_nAgreedSuit); bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); return TRUE; } // else pass nBid = BID_PASS; status << "NGDRb90! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " points in the partnership, we have insufficient strength to raise partner's " & BTS(nPartnersBid) & " bid, so we have to pass.\n"; bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } } // //-------------------------------------------------------------------------- // here, we have no suit agreement (e.g., partner bid the opponents' suit) // int nLastBid = pDOC->GetLastValidBid(); if (bBalanced) { // try notrumps if (hand.IsSuitProbablyStopped(nEnemySuit)) { status << "NGDRb80! Without clear suit agreement, and holding a blanaced hand, we want to steer towards a contract in No Trump.\n"; if (bidState.BidNoTrumpAsAppropriate(FALSE,STOPPED_DONTCARE)) { bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); return TRUE; } } // else pass status << "NGDRb81! But as we do not have a proper hand to bid No Trump at the appropriate level, we have to pass.\n"; bidState.SetBid(BID_PASS); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } else if (bidState.numPrefSuitCards >= 5) { // bid the suit nBid = bidState.GetCheapestShiftBid(nPrefSuit, nLastBid); if (bidState.IsBidSafe(nBid, 4)) { if (bWantedToOvercall) status << "NGDRb90! Partner's forced response of " & bidState.szPB & " not withstanding, we can now show the " & STSS(nPrefSuit) & " suit that we wanted to overcall with last round by bidding " & BTS(nBid) & ".\n"; else status << "NGDRb91! Without clear suit agreement, we bid our " & bidState.numPrefSuitCards & "-card " & STSS(bidState.nPrefSuit) & " suit at " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); return TRUE; } } // //-------------------------------------------------------------------------- // else we have no other options, so pass status << "NEGDRb99! We see no good fit with partner and no other options, so pass.\n"; bidState.SetBid(BID_PASS); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } else { // // responding after partner's second response to our takeout // // did partner pass? if (nPartnersBid == BID_PASS) { bidState.SetConventionStatus(this, CONV_FINISHED); return FALSE; } // // otherwise, consider the choices: // // - with suit agreement, raise if possible // S N S N S // e.g., X -> 1C -> 1S -> 2S -> ??? // - without suit agreement, // e.g., X -> 1C -> 1S -> 2H -? ??? // bid the 4th suit if we have the pts (26+) // - without suit agreement, but if partner bids NT, // or if we have a balanaced hand, bid NT // double fMinTPPoints = bidState.m_fMinTPPoints; double fMaxTPPoints = bidState.m_fMaxTPPoints; double fMinTPCPoints = bidState.m_fMinTPCPoints; double fMaxTPCPoints = bidState.m_fMaxTPCPoints; int nBid; // // see if we have suit agreement // if (nPartnersSuit == nPreviousSuit) { // partner raised our suit -- re-raise if possible bidState.m_nAgreedSuit = nPreviousSuit; if (nPartnersBid >= bidState.GetGameBid(nPreviousSuit)) { // partner bid game or beyond if ((nPartnersBidLevel == 7) || ((nPartnersBidLevel == 6) && (fMinTPPoints <= 36)) ) { nBid = BID_PASS; status << "NGDRc10! Partner raised our " & bidState.szPVSS & " suit to a slam, so pass.\n"; } else if ((nPartnersBidLevel <= 6) && (fMinTPPoints >= 37)) { nBid = MAKEBID(nPreviousSuit, 7); status << "NGDRc11! Partner raised our " & bidState.szPVSS & " suit to " & ((nPartnersBidLevel == 6)? "slam" : "game") & ", but we have the poitns to push to a grand slam, so bid " & BTS(nBid) & ".\n"; } else if ((nPartnersBidLevel < 6) && (fMinTPPoints >= 33)) { nBid = MAKEBID(nPreviousSuit, 6); status << "NGDRc12! Partner raised our " & bidState.szPVSS & " suit to game, but we have the poitns for a slam, so bid " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "NGDRc13! Partner raised our " & bidState.szPVSS & " suit to game, which is acceptable with " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, so pass.\n"; } } else { // partner raised below game // re-raise if possible if ( (ISMAJOR(nPreviousSuit) && (fMinTPPoints >= PTS_MAJOR_GAME)) || (ISMINOR(nPreviousSuit) && (fMinTPPoints >= PTS_MINOR_GAME)) ) { nBid = bidState.GetGameBid(nPreviousSuit); status << "NGDRc20! With a total of " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, raise to game in the " & bidState.szPVSS & " suit at " & BTS(nBid) & ".\n"; } else { // else try to raise cheaply nBid = bidState.GetCheapestShiftBid(nPreviousSuit); if (bidState.IsBidSafe(nBid)) { status << "NGDRc22! With a total of " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, we can raise again to " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "NGDRc29! With a total of " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, we cannot safely raise any partner further, so pass.\n"; } } } } else if ((nPartnersSuit == NOTRUMP) || (bidState.bBalanced)) { // // partner bid NT, or else we have a balanced hand // if (bidState.BidNoTrumpAsAppropriate(FALSE, STOPPED_DONTCARE)) { nBid = bidState.m_nBid; status << "NGDRc30! With a total of " & fMinTPCPoints & "-" & fMaxTPCPoints & " HCPs in the partnership, we can bid " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; if (nPartnersSuit == NOTRUMP) status << "NGDRc35! We're willing to accept a contract in NoTrumps, but don't have the points to raise further, so pass.\n"; else status << "NGDRc36! We'd like to play in NoTrumps, but don't have the points to bid agian, so pass.\n"; } } else { // // else we have no suit agreement, and can't play NT // // // bid the 4th suit if we have enough pts // int nSuit = bidState.GetFourthSuit(nPreviousSuit, nPartnersSuit, nPartnersPrevSuit); nBid = bidState.GetCheapestShiftBid(nSuit); if ((fMinTPPoints >= PTS_GAME) && (nBid < bidState.GetGameBid(nSuit))) { status << "NGDRc40! With a total of " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership and no suit agreement, bid another suit (" & STS(nSuit) & ") at " & BTS(nBid) & ".\n"; } else { // gotta pass nBid = BID_PASS; if (nPartnersBid >= bidState.GetGameBid(nPartnersSuit)) status << "NGDRc45! With a total of " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, partner has gone to game in his suit at " & bidState.szPB & ", so pass.\n"; else if (fMinTPPoints >= PTS_GAME) status << "NGDRc46! With a total of " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, but having run out of bidding room, we have to bail out and pass.\n"; else status << "NGDRc47! With a total of only " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, and no agreement in suits, we have to pass.\n"; } } // done with the second rebid bidState.SetBid(nBid); bidState.ClearConventionStatus(this); return TRUE; } }
// //--------------------------------------------------------- // BOOL CEasyBDoc::ReadFilePBN(CArchive& ar) { int nLineCode, nValue, nCode; CString strMessage, string, strTag, strValue, partString, strModifier; double fValue; BOOL bValue; CString strLine; // init some flags m_bReviewingGame = FALSE; m_bGameReviewAvailable = FALSE; // preload the file numLines = PreloadPBNFile(ar, strLines); /* int sizeOf = strLines.GetSize(); // NCR DEBUG ONLY for(int xxx = 0; xxx < sizeOf; xxx++) { CString nxtStr = strLines.GetAt(xxx); ASSERT(!nxtStr.IsEmpty()); } */ // read in the ines pGameRecord = NULL; m_nLineNumber = 0; nGameIndex = 0; nPreviousTag = 0; int numGamesLoaded = 0; int numInvalidGames = 0; int numTagsRead = 0; int numDeclarers = 0; // NCR use to test reviewable deals ie no Declarer means no review // for(;;) { // check for EOF if (m_nLineNumber >= numLines) break; strBuf = strLines.GetAt(m_nLineNumber++); // strBuf.TrimLeft(); strBuf.TrimRight(); nLineLen = strBuf.GetLength(); // see if this is a blank line (but watch out for multiple empty lines) if (strBuf.IsEmpty()) { // flush out the current game if (pGameRecord) { pGameRecord->AnalyzePlayRecord(); if (pGameRecord->IsValid(isExportFile)) // NCR_PBNI added isExportFile { m_gameRecords.Add(pGameRecord); numGamesLoaded++; nGameIndex++; } else { delete pGameRecord; numInvalidGames++; } pGameRecord = NULL; nPreviousTag = 0; continue; } } // else parse the line for tokens nLineCode = ParseLinePBN(strBuf, strTag, strValue, nLineLen); // check for error if (nLineCode < 0) { // junk tag? if (m_nLineNumber == 0) { AfxMessageBox("This is not a proper PBN format file."); AfxThrowFileException(CFileException::generic); } continue; } // // else the tag is OK // // see if the value is "#" -- then substitute if ((strValue == "#") && (nGameIndex > 0)) { // look up the value from the previous game CGameRecord* pPrevGame = m_gameRecords[nGameIndex-1]; std::map<CString,CString>::const_iterator iter = pPrevGame->m_mapTagValues.find(strTag); if (iter != pPrevGame->m_mapTagValues.end()) strValue = (*iter).second; } // // get data value // nValue = atoi(strValue); fValue = atof(strValue); if ((strValue == "Yes") || (strValue == "1")) bValue = TRUE; else bValue = FALSE; // // if this is a valid tag, alloc a new game object // if ((!strTag.IsEmpty()) && (pGameRecord == NULL)) { pGameRecord = new CGameRecord; numTagsRead = 0; } // //------------------------------------------------------------------- // // process item // switch(nLineCode) { case TAG_EVENT: break; case TAG_SITE: // ignore for now break; case TAG_DATE: // ignore for now break; case TAG_ROUND: // ignore for now break; case TAG_BOARD: // ignore for now break; case TAG_WEST: // ignore for now break; case TAG_NORTH: // ignore for now break; case TAG_EAST: // ignore for now break; case TAG_SOUTH: // ignore for now break; // dealer case TAG_DEALER: if (!strValue.IsEmpty() && (strValue[0] != '?')) pGameRecord->m_nDealer = CharToPosition(strValue[0]); break; // vulnerability case TAG_VULNERABLE: if (strValue.CompareNoCase("NS") == 0) pGameRecord->m_nVulnerability = NORTH_SOUTH; else if (strValue.CompareNoCase("EW") == 0) pGameRecord->m_nVulnerability = EAST_WEST; else if ((strValue.CompareNoCase("All") == 0) || (strValue.CompareNoCase("Both") == 0)) pGameRecord->m_nVulnerability = BOTH; else if((strValue.CompareNoCase("None") == 0) || (strValue.CompareNoCase("-") == 0)) // NCR-PBNI pGameRecord->m_nVulnerability = NEITHER; else // error if not above AfxMessageBox("Invalid Vulnerabliity: " + strValue); break; case TAG_DEAL: // AssignCardsPBN(strValue); break; case TAG_SCORING: // ignore for now break; case TAG_DECLARER: if (!strValue.IsEmpty() && (strValue[0] != '?')) { pGameRecord->m_nDeclarer = CharToPosition(strValue[0]); numDeclarers++; // NCR count for need to do review } break; case TAG_CONTRACT: { // decipher the contract if ((strValue.GetLength() < 2) || (strValue[0] == '?')) { // contract has not yet been set theApp.SetValue(tbGameInProgress, FALSE); break; } int nContractLevel = atoi(strValue); int nContractSuit = CharToSuit(strValue[1]); int nContract = MAKEBID(nContractSuit, nContractLevel); int nContractModifier = 0; // pGameRecord->m_nContract = nContract; // get modifier if (nContractSuit == NOTRUMP) strModifier = strValue.Mid(3); else strModifier = strValue.Mid(2); if (strModifier.CompareNoCase("X") == 0) nContractModifier = 1; else if (strModifier.CompareNoCase("XX") == 0) nContractModifier = 2; // pGameRecord->m_nContractModifier = nContractModifier; break; } case TAG_RESULT: // ignore for now break; // ge the auction case TAG_AUCTION: if (strValue.IsEmpty()) break; // parse the bids nCode = ParseBidsPBN(ar, strValue); break; case TAG_PLAY: // read in the plays if (strValue.IsEmpty() || (strValue[0] == '?')) break; // parse the plays nCode = ParsePlaysPBN(ar, strValue); // mark this file as being reviewable if (ISBID(pGameRecord->m_nContract)) { // contract must also be valid m_bReviewingGame = TRUE; m_bGameReviewAvailable = TRUE; } break; case TAG_NOTE: // add to the appropriate list if (nPreviousTag == TAG_AUCTION) pGameRecord->m_strBiddingNotes.Add(strValue); else if (nPreviousTag == TAG_PLAY) pGameRecord->m_strPlayNotes.Add(strValue); break; case TAG_OPTIMUMSCORE: // NCR-776 for BridgeWebs files // ignore break; case TAG_TERMINATOR: // ignore for now break; } // end switch(nLineCode) // save this tag nPreviousTag = nLineCode; numTagsRead++; // save the tag-value pair in the map if (pGameRecord) { // but don't save notes here if (strTag.CompareNoCase("Note") != 0) pGameRecord->SetTagValue(strTag, strValue); } } // end for(;;) // see if the file ended with no ending empty line // if (nGameIndex == 0 && pGameRecord) if (pGameRecord && (numTagsRead >= 1)) { pGameRecord->AnalyzePlayRecord(); if (pGameRecord->IsValid(isExportFile)) // NCR-PBNI added isExportFile { m_gameRecords.Add(pGameRecord); numGamesLoaded++; nGameIndex++; } // pGameRecord = NULL; } // if the file has > 1 game record, set game review mode if (nGameIndex > 1) { m_bReviewingGame = TRUE; m_bGameReviewAvailable = TRUE; } // see if we have a dangling (invalid) game object if (pGameRecord) delete pGameRecord; // all done return TRUE; }
// //----------------------------------------------------- // // handle an artificial 2C opening bid (23+ pts) // BOOL CArtificial2ClubConvention::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; // // Bidding in response to an opening 2C bid? check requirements // int nPartnersBid = bidState.nPartnersBid; int nPartnersSuit = bidState.nPartnersSuit; int nPartnersSuitSupport = bidState.nPartnersSuitSupport; int numSupportCards = bidState.numSupportCards; int nPartnersBidLevel = bidState.nPartnersBidLevel; int numPartnerBidsMade = bidState.m_numPartnerBidsMade; int nBid; // see if this is our second response to partner's opening 2C bid if (bidState.GetConventionStatus(this) == CONV_RESPONDED) { // see if we responded 2D last time if (bidState.nPreviousBid == BID_2D) { status << "R2CLR2! Partner showed his best suit of " & bidState.szPS & " in response to our negative 2D response.\n"; // what to do here??? // if partner shows a suit, adjust point count as dummy double fAdjPts = bidState.fAdjPts = (ISSUIT(bidState.nPartnersSuit))? hand.RevalueHand(REVALUE_DUMMY, bidState.nPartnersSuit, TRUE) : bidState.fPts; double fCardPts = bidState.fCardPts; // adjust partnership point count minimums & maximums bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; // if (bidState.m_fMinTPPoints <= PTS_GAME-2) { nBid = BID_PASS; status << "R2CLR10! But with only " & bidState.m_fMinTPPoints & " points in the partnership, we have to pass.\n"; } else { // either shift to our own suit, raise partner to game, or bid 3NT if ((nPartnersSuitSupport >= SS_MODERATE_SUPPORT) && (nPartnersBid < bidState.GetGameBid(nPartnersSuit))) { nBid = bidState.GetGameBid(nPartnersSuit); status << "R2CLR20! Raise partner's & " & bidState.szPS & " to game at "& BTS(nBid) & ".\n"; } else if (bidState.IsSuitOpenable(bidState.nPrefSuit) && (nPartnersBidLevel <= 3)) { nBid = bidState.GetCheapestShiftBid(bidState.nPrefSuit); status << "R2CLR22! Bid our own " & bidState.szPrefSS & " suit in preference to partner's " & bidState.szPSS & " suit .\n"; } else if (nPartnersBid < BID_3NT) { nBid = BID_3NT; status << "R2CLR25! With only " & bidState.SLTS(nPartnersSuit) & " support for partner and no good suit of our own, bid 3NT.\n"; } else { nBid = BID_PASS; status << "R2CLR30! With only " & bidState.SLTS(nPartnersSuit) & " support for partner and no good suit of our own, we have to pass.\n"; } } // bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // mark this convention as completed bidState.SetConventionStatus(this, CONV_FINISHED); return FALSE; } // // // partner must've bid 2 Club at his first opportunity, // and partner's bid must have been the first bid made // if ((nPartnersBid == BID_2C) && (bidState.m_bPartnerOpenedForTeam) && (numPartnerBidsMade == 1) && (nPartnersBid == pDOC->GetValidBidRecord(0))) { // condition valid // record that we responded bidState.SetConventionStatus(this, CONV_RESPONDED); } else { return FALSE; } // state expectations status << "R2CLUB! Partner made an artificial bid of 2 Clubs, showing either a game suit or " & pCurrConvSet->GetValue(tn2ClubOpeningPoints) & "+ points. We want to respond positively if interested in a slam.\n"; // the bid is forcing to game bidState.m_bGameForceActive = TRUE; // double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; double fCardPts = bidState.fCardPts; int nPrefSuit = bidState.nPrefSuit; int nPrefSuitStrength = bidState.nPrefSuitStrength; // bidState.AdjustPartnershipPoints(pCurrConvSet->GetValue(tn2ClubOpeningPoints), 40 - fCardPts); // respond negatively (2D) with < 33 points if (bidState.m_fMinTPPoints < PTS_SLAM) { nBid = BID_2D; status << "R2C04! With only " & fCardPts & "/" & fPts & " points, we deny interest in slam by making the negative response of " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // // else with 33+ points, state slam hopes // status << "2R2C08! With a total of " & bidState.m_fMinTPPoints & "+ points in the partnership, we want to invite slam.\n"; // show an openable suit if (nPrefSuitStrength >= SS_OPENABLE) { if (ISMAJOR(nPrefSuit)) nBid = MAKEBID(nPrefSuit,2); else nBid = MAKEBID(nPrefSuit,3); status << "R2C14! With " & fCardPts & "/" & fPts & " points in hand, and a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " points in the partnership, we express possible interest in slam by showing our best suit (" & bidState.szPrefS & ") with a bid of " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // or a SOLID suit (jump shift) if (bidState.bPrefSuitIsSolid) { if (ISMAJOR(nPrefSuit)) nBid = MAKEBID(nPrefSuit,3); else nBid = MAKEBID(nPrefSuit,4); status << "R2C18! With " & fCardPts & "/" & fPts & " points in hand and a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " points in the partnership, we express interest in a slam by showing our solid " & bidState.szPrefSS & " suit in a jump bid of " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // else assume a balanced hand // with a balanced hand & >= 26 total HCPs, bid 3NT; // with < 26 total HCPs, 2NT if (bidState.bBalanced) { if (bidState.m_fMinTPCPoints >= PTS_NT_GAME) nBid = BID_3NT; else nBid = BID_2NT; status << "R2C22! With " & fCardPts & " HCPs and a balanced hand, and a total of " & bidState.m_fMinTPCPoints & "+ HCPs in the partnership, we respond with " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // else just bid the best suit nBid = bidState.GetCheapestShiftBid(nPrefSuit, BID_2C); status << "R2C26! With " & fCardPts & "/" & fPts & " points but with no strong suit and an unbalanced hand, we have to respond with our best suit of " & bidState.szPrefS & " by bidding " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // end of 2C opening section
// //================================================================== // // BOOL C4thSuitForcingConvention::TryConvention(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { // // if (!pCurrConvSet->IsConventionEnabled(tid4thSuitForcing)) // return FALSE; // // see if the conditions are right to apply this convention // int nPartnersSuit = bidState.nPartnersSuit; int nPartnersPrevSuit = bidState.nPartnersPrevSuit; int nFirstRoundSuit = bidState.nFirstRoundSuit; int nPreviousSuit = bidState.nPreviousSuit; // NCR-342 Quick test if 4 suits were bid if ((bidState.m_numBidsMade != 2) || (bidState.m_numPartnerBidsMade != 2) || !ISSUIT(nPartnersSuit) || !ISSUIT(nPartnersPrevSuit) || !ISSUIT(nFirstRoundSuit) || !ISSUIT(nPreviousSuit) ) { return FALSE; // NCR-342 Not possible without these } /* //NCR NB- Following logic is weak??? if ((bidState.m_numBidsMade == 2) && // NCR-334 changed to 2 (was 1) (bidState.m_numPartnerBidsMade == 2) && (nPartnersSuit != nPartnersPrevSuit) && (nPartnersPrevSuit != NONE) && (nFirstRoundSuit != nPreviousSuit) && (nFirstRoundSuit != NONE) && (nFirstRoundSuit != NOTRUMP) && // NCR-338 NT not a suit (nPartnersSuit != NOTRUMP)) \ */ // NCR-342 Now test 4 suits bid bool suitBid[4] = {false, false, false, false}; suitBid[nPartnersSuit] = true; suitBid[nPartnersPrevSuit] = true; suitBid[nFirstRoundSuit] = true; suitBid[nPreviousSuit] = true; if(suitBid[CLUBS] && suitBid[DIAMONDS] && suitBid[HEARTS] && suitBid[SPADES]) { // // since we're playing 4th suit forcing, we can't pass // partner's bid, no matter what // status << "SF0! Since we're playing fourth-suit forcing, we are required to respond to partner's bid of the 4th suit.\n"; int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPrefSuit = bidState.nPrefSuit; int nPrefSuitStrength = bidState.nPrefSuitStrength; double fMinTPPoints = bidState.m_fMinTPPoints; double fMaxTPPoints = bidState.m_fMaxTPPoints; double fMinTPCPoints = bidState.m_fMinTPCPoints; double fMaxTPCPoints = bidState.m_fMaxTPCPoints; int nBid; // // choice 1: rebid a strong major, if it's our preferred suit, with 22+ pts // if ((ISMAJOR(nPrefSuit)) && (nPrefSuitStrength >= SS_STRONG) && (fMinTPPoints >= 22)) { nBid = bidState.GetCheapestShiftBid(nPrefSuit); status << "SF2! With no agreement in suits, along with " & fMinTPPoints & "-" & fMaxTPPoints & " partnership points, return to our preferred " & bidState.szPrefSS & " suit at " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // // bid 3NT with no voids and 26+ HCPs // if ((bidState.numVoids == 0) && (nPartnersBidLevel <= 3) && (fMinTPCPoints >= PTS_NT_GAME)) { nBid = BID_3NT; status << "SF4! With no agreement in suits, but with " & fMinTPCPoints & "-" & fMaxTPCPoints & " high card points in the partnership and no void suits, bid " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // // raise one of partner's suits with 23+ points and 2-card support // int nSuit; if (bidState.nPPrevSuitSupport > bidState.nPartnersSuitSupport) nSuit = SUIT_PREV; else nSuit = SUIT_ANY; // raise to game level with 26+ total pts if (bidState.RaisePartnersSuit(SUIT_PREV,RAISE_TO_NO_MORE_THAN_GAME,PTS_GAME,99,SUPLEN_2)) { // the bid (m_nBid) is set automatically return TRUE; } // raise to 3-level with 23 pts if (bidState.RaisePartnersSuit(SUIT_PREV,RAISE_TO_3,PTS_GAME-3,99,SUPLEN_2)) { return TRUE; } // // bid 2NT with no voids // if ((bidState.numVoids == 0) && (nPartnersBidLevel <= 2)) { nBid = BID_2NT; status << "SF10! With no agreement in suits, but with " & // NCR changed from 4 to 10 fMinTPCPoints & "-" & fMaxTPCPoints & " high card points in the partnership and no void suits, bid " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // // else we've run out of other options, so // raise partner's first or second suit with single-card support // if (bidState.numCardsInSuit[nPartnersPrevSuit] >= 1) { nBid = bidState.GetCheapestShiftBid(nPartnersPrevSuit); status << "SF20! With no better options, raise partner's first suit to " & BTS(nBid) & ".\n"; } else { nBid = MAKEBID(nPartnersSuit, nPartnersBidLevel+1); status << "SF24! With no better options, raise partner's second suit to " & BTS(nBid) & ".\n"; } // done bidState.SetBid(nBid); return TRUE; } else { // the 4th suit forcing convention didn't apply here return FALSE; } }
// //========================================================= // // RespondToConvention() // // respond to partner's preemptive shutout bid of 3, 4, or 5 // BOOL CShutoutBidsConvention::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()) return FALSE; // // Bidding in response to an opening preemptive shutout bid? // check requirements // int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPartnersSuit = bidState.nPartnersSuit; // // check to see if partner did in fact make a shutout bid // if (((nPartnersBidLevel >= 3) && (nPartnersBidLevel <= 5)) && (bidState.m_numPartnerBidsMade == 1) && (nPartnersSuit != NOTRUMP) && (bidState.m_bPartnerOpenedForTeam)) { // okay, met requirements } else { // failed the test return FALSE; } // // in general, pass a shutout bid unless we have an exceedingly // strong hand // // first state expectations bidState.m_fPartnersMin = OPEN_PTS(6); bidState.m_fPartnersMax = OPEN_PTS(9); status << "SHUTR0! Partner made a preemptive " & bidState.szPB & " bid, showing a " & ((bidState.nPartnersBidLevel==3)? 7:(bidState.nPartnersBidLevel==4)? 8:9) & "-card " & bidState.szPSS & " suit with no tricks outside the suit, and most likely " & bidState.m_fPartnersMin & "-" & bidState.m_fPartnersMax & " points.\n"; // adjust team point estimates double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; double fCardPts = bidState.fCardPts; bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; // raise a 3 bid to game if we have enough to make game // the requiremetns are: // 1: 4 cards in the suit, // 2: 5 playing tricks for a major suit, or 6 for a minor // 3: 2 QT's, and // 4: >= 26 team pts for a major game, or >= 29 pts for a minor game int nBid; int numSupportCards = bidState.numSupportCards; int nPartnersSuitSupport = bidState.nPartnersSuitSupport; double numQuickTricks = bidState.numQuickTricks; int numLikelyWinners = bidState.numLikelyWinners; double fMinTPPoints = bidState.m_fMinTPPoints; double fMaxTPPoints = bidState.m_fMaxTPPoints; // if ((nPartnersBidLevel == 3) && (ISMAJOR(nPartnersSuit)) && (numSupportCards >= 4) && (numQuickTricks >= 2) && (numLikelyWinners >= 5) && (fMinTPPoints >= PTS_GAME)) { nBid = MAKEBID(nPartnersSuit,4); status << "SHUTR2! We have " & fCardPts & "/" & fPts & "/" & fAdjPts & " points in hand, for a total of " & fMinTPPoints & "-" & fMaxTPPoints & " points in the partnership, strong support for partner's long " & bidState.szPSS & " suit (holding " & bidState.szHP & "), plus " & numQuickTricks & " QTs and " & numLikelyWinners & " likely winners, so we can safely bid game at " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // raise a minor to game as above, but with 5-card // support && 6+ winners && 28+ TPs if ((nPartnersBidLevel <= 4) && (ISMINOR(nPartnersSuit)) && (numSupportCards >= 5) && (numQuickTricks >= 2) && (numLikelyWinners >= 6) && (fMinTPPoints >= PTS_MINOR_GAME)) { nBid = MAKEBID(nPartnersSuit,5); status << "SHUTR4! We have " & fCardPts & "/" & fPts & "/" & fAdjPts & " points in hand, for a total of " & fMinTPPoints & "-" & fMaxTPPoints & " points in the partnership, strong support for partner's long " & bidState.szPSS & " suit (holding " & bidState.szHP & "), plus " & numQuickTricks & " QTs and " & numLikelyWinners & " likely winners, so we can safely bid a minor game at " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // raise a 3 or 4 bid to slam with strong support, // >= 32 TPs, and 4 QTs if ((nPartnersBidLevel < 5) && (nPartnersSuitSupport >= SS_GOOD_SUPPORT) && (numQuickTricks >= 4) && (fMinTPPoints >= PTS_SLAM)) { nBid = MAKEBID(nPartnersSuit,6); status << "SHUTR6! We have " & fCardPts & "/" & fPts & "/" & fAdjPts & " points in hand, for a total of " & fMinTPPoints & "-" & fMaxTPPoints & " points in the partnership, " & bidState.SLTS(nPartnersSuit) & " support for partner's long " & bidState.szPSS & " suit (holding " & bidState.szHP & "), plus " & numQuickTricks & " QTs, so we can safely bid a slam at " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); return TRUE; } // else, just pass nBid = BID_PASS; status << "SHUTR9! With " & fCardPts & "/" & fPts & "/" & fAdjPts & " points in hand, for a total of " & fMinTPPoints & "-" & fMaxTPPoints & " points in the partnership, holding " & bidState.szHP & " in support of partner's " & bidState.szPSS & " suit, and with only " & numQuickTricks & " QTs and " & numLikelyWinners & " likely winners, we have no real reason to bid anything, so just pass.\n"; bidState.SetBid(nBid); return TRUE; }
// //--------------------------------------------------------------- // // HandleConventionResponse() // // Check on Gerber response from the invoker, and act accordingly // // BOOL CGerberConvention::HandleConventionResponse(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { int nGerberStatus = bidState.GetConventionStatus(this); int numAces = bidState.numAces; int numKings = bidState.numKings; double fMinTPPoints = bidState.m_fMinTPPoints; double fMaxTPPoints = bidState.m_fMaxTPPoints; double fMinTPCPoints = bidState.m_fMinTPCPoints; double fMaxTPCPoints = bidState.m_fMaxTPCPoints; int nAgreedSuit = bidState.m_nAgreedSuit; int nPartnersBid = bidState.nPartnersBid; int nBid; // // Did we ask partner for aces in our last bid? // if (nGerberStatus == 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); } // switch(nPartnersBid) { // case BID_4D: // 0 or 4 Aces if (numAces == 0) bidState.m_numPartnersAces = 4; else bidState.m_numPartnersAces = 0; break; case BID_4H: // 1 Ace bidState.m_numPartnersAces = 1; break; case BID_4S: // 2 Aces bidState.m_numPartnersAces = 2; break; case BID_4NT: // 3 Aces bidState.m_numPartnersAces = 3; break; default: // choke, gag, spew! bidState.m_numPartnersAces = 0; break; } if (nPartnersBid <= BID_4NT) { status << "GRB20! Partner responded to our 4C Gerber inquiry with " & BTS(nPartnersBid) & ", indicating " & bidState.m_numPartnersAces & (((bidState.m_numPartnersAces == 0) || (bidState.m_numPartnersAces > 1))? " Aces" : " Ace") & ".\n"; } else { status << "GRB22! Partner made an illegal " & BTS(bidState.nPartnersBid) & " response to 4C Gerber; assuming zero Aces in partner's hand.\n"; bidState.SetConventionStatus(this, CONV_ERROR); // Gerber complete return TRUE; } // // at this point, decide whether to pass, proceed to asking for kings, // or jump to a contract. // int numTotalAces = bidState.numAces + bidState.m_numPartnersAces; // if (numTotalAces == 4) { // if we're close to a grand slam, go for it if (fMinTPPoints >= PTS_GRAND_SLAM-1) { nBid = BID_5NT; status << "GRB32! Our team holds all four aces, so proceed to 5NT to ask for kings.\n"; nGerberStatus = CONV_INVOKED_ROUND2; // asking for kings } else { nBid = MAKEBID(nAgreedSuit, 6); status << "GRB32! Our team holds all four aces, but with an estimated " & fMinTPPoints & "-" & fMaxTPPoints & " total partnership points, we lack the points for a grand slam, so settle for a contract of " & BTS(nBid) & ".\n"; nGerberStatus = CONV_FINISHED; // Gerber finished } } else { // oops, we don't have all 4 aces, so we gotta stop // if we have 3 or fewer aces and less than 32 pts. then really panic // NCR-246a Need 3 aces and points to continue if ((numTotalAces < 3) || (bidState.m_fMinTPPoints < PTS_SLAM) || (bidState.m_fMaxTPCPoints < PTS_SLAM) ) { // NCR-246a See if we need to bid int nTestBid = BID_PASS; // NCR-246a pass if at game in our suit if(( bidState.nPartnersSuit != nAgreedSuit) || !bidState.IsGameBid(bidState.nPartnersBid)) { nTestBid = bidState.GetCheapestShiftBid(nAgreedSuit); } if (nTestBid <= BID_5NT) { // if we can return to the trump suit at the 5 level, // then do so nBid = nTestBid; status << "GRB34! Oops, we're caught with only " & numTotalAces & " Aces and as few as " & bidState.m_fMinTPPoints & " total points, so halt the bidding at the " & BID_LEVEL(nPartnersBid) & "-level.\n"; // NCR replaced five with BID_LEVEL() } else { nBid = MAKEBID(nAgreedSuit, 6); } } else { if( bidState.numSuitsStopped < 4) // NCR-325 don't try slam without all 4 stopped { nBid = bidState.GetCheapestShiftBid(nAgreedSuit); //NCR-325 get cheap bid }else nBid = MAKEBID(nAgreedSuit, 6); } status << "GRB38! Without all four aces we can't proceed to a grand slam, so stop at " & BTS(nBid) & ".\n"; nGerberStatus = CONV_FINISHED; // Gerber finished } // update status and return bidState.SetBid(nBid); bidState.SetConventionStatus(this, nGerberStatus); return TRUE; } // // Did we ask for kings? // if (nGerberStatus == 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); } // switch(nPartnersBid) { // case BID_5D: // 0 or 4 Kings if (numKings == 0) bidState.m_numPartnersKings = 4; else bidState.m_numPartnersKings = 0; break; case BID_5H: // 1 King bidState.m_numPartnersKings = 1; break; case BID_5S: // 2 Kings bidState.m_numPartnersKings = 2; break; case BID_5NT: // 3 Kings bidState.m_numPartnersKings = 3; break; default: // choke, gag, spew! bidState.m_numPartnersKings = 0; break; } if (nPartnersBid <= BID_5NT) { status << "GRB40! Partner responded to our 4C Gerber inquiry with " & BTS(nPartnersBid) & ", indicating " & bidState.m_numPartnersKings & ((bidState.m_numPartnersKings > 1)? " Kings" : " King") & ".\n"; } else { status << "GRB44! Partner made an illegal " & BTS(nPartnersBid) & " response to 4C Gerber inquiry; assuming zero Kings in partner's hand.\n"; nBid = BID_PASS; bidState.SetConventionStatus(this, CONV_ERROR); return FALSE; } // // at this point, decide on a contract. // int numTotalAces = bidState.numAces + bidState.m_numPartnersAces; ASSERT(numTotalAces == 4); int numTotalKings = bidState.numKings + bidState.m_numPartnersKings; // if (numTotalKings == 4) { // we have all Aces & Kings, so bid a grand slam nBid = MAKEBID(nAgreedSuit, 7); status << "GRB45! We have all the aces and kings, plus a total of " & fMinTPPoints & "-" & fMaxTPPoints & " points in the partnership, so go ahead and bid " & BTS(nBid) & ".\n"; } else if ((numTotalKings == 3) && (fMinTPPoints >= PTS_GRAND_SLAM)) { // we're missing a king but have good pts, so go for a grand nBid = MAKEBID(nAgreedSuit, 7); status << "GRB46! We're missing one King, but with a total of " & fMinTPPoints & "-" & fMaxTPPoints & " points in the partnership, we can go ahead and bid " & BTS(nBid) & ".\n"; } else if ((numTotalKings >= 3) && (fMinTPPoints >= PTS_GRAND_SLAM+1)) { // we're missing two kings but have good pts, so go for a grand nBid = MAKEBID(nAgreedSuit, 7); status << "GRB47! We may not have all the kings, but with a total of " & fMinTPPoints & "-" & fMaxTPPoints & " points in the partnership, go ahead and bid " & BTS(nBid) & ".\n"; } else { // we're missing two or more kings, so settle for a small slam nBid = MAKEBID(nAgreedSuit, 6); if (nBid > nPartnersBid) { // bail out at 6 of the agreed suit status << "GRB48! Since we're missing " & (4 - numTotalKings) & " Kings and have a total of only " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, we lack sufficient strength for a grand slam and have to settle for a small slam at " & BTS(nBid) & ".\n"; } else { // bail out at 6NT nBid = BID_6NT; status << "GRB49! Since we're missing " & (4 - numTotalKings) & " Kings and have a total of only " & fMinTPCPoints & "-" & fMaxTPCPoints & " HCPs in the partnership, we lack sufficient strength for a grand slam and have to settle for a small slam at " & BTS(nBid) & ".\n"; } } // update status and return bidState.SetBid(nBid); nGerberStatus = 3; bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // return FALSE; }
// //--------------------------------------------------------------- // // InvokeGerber() // // Start the Gerber convention // BOOL CGerberConvention::InvokeGerber(CHandHoldings& hand, CBidEngine& bidState, CPlayerStatusDialog& status, int nEventualSuit) { // record intended suit for later use ASSERT(nEventualSuit != NONE); bidState.m_nAgreedSuit = nEventualSuit; double fMinTPPoints = bidState.m_fMinTPPoints; double fMaxTPPoints = bidState.m_fMaxTPPoints; double fMinTPCPoints = bidState.m_fMinTPCPoints; double fMaxTPCPoints = bidState.m_fMaxTPCPoints; double fCardPts = bidState.fCardPts; double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; int nBid; // if Gerber has already been used, return if (bidState.GetConventionStatus(this) >= CONV_INVOKED) return FALSE; // // if Gerber is not enabled, just bid slam directly // if (!pCurrConvSet->IsConventionEnabled(tidGerber)) { // no Gerber? go ahead and bid slam directly status << "2GERBX! we have " & fCardPts & "/" & fPts & "/" & fAdjPts & " points in hand, for a total of approx. " & fMinTPPoints & "-" & fMaxTPPoints & " / " & fMinTPCPoints & "-" & fMaxTPCPoints & " pts in the partnership, but we can't use Gerber to investigate Aces and Kings since it's currently not enabled.\n"; // bid a grand slam if we have 37+ pts and the trump ace // or a small slam with 32+ points // or make the cheapest shift bid otherwise (D'oh!) if ((fMinTPPoints >= PTS_GRAND_SLAM+1) && (hand.SuitHasCard(nEventualSuit, ACE))) { nBid = MAKEBID(nEventualSuit, 7); status << "2GERBX1! but since we have the points for a grand slam and we hold the trump ace, go ahead and bid " & BTS(nBid) & ".\n"; } else if (fMinTPPoints >= PTS_SLAM) { nBid = MAKEBID(nEventualSuit, 6); status << "2GERBX2! but since we have the points for a small slam, go ahead and bid " & BTS(nBid) & ".\n"; } else { // get cheapest shift bid nBid = bidState.GetCheapestShiftBid(nEventualSuit); status << "2GERBX3! so we just bid " & BTS(nBid) & ".\n"; } // bidState.SetBid(nBid); return TRUE; } // // shouldn't use Gerber if we have all four aces // if (bidState.numAces == 4) { // no Gerber? go ahead and bid slam directly status << "2GERBY! Unfortunately, since we hold all four aces, Gerber is of little value to us.\n"; // bid a grand slam if we have 37+ pts and the trump ace // or a small slam with 32+ points // or make the cheapest shift bid otherwise (D'oh!) if ((fMinTPPoints >= PTS_SLAM+1) // NCR-324 added NOTRUMP test && ((nEventualSuit == NOTRUMP) || (hand.SuitHasCard(nEventualSuit, ACE)))) { nBid = MAKEBID(nEventualSuit, 7); status << "2GERBY1! so since we have the points for a grand slam, go ahead and bid " & BTS(nBid) & ".\n"; } else if (fMinTPPoints >= PTS_SLAM) { nBid = MAKEBID(nEventualSuit, 6); status << "2GERBY2! so since we have the points for a small slam, go ahead and bid " & BTS(nBid) & ".\n"; } else { nBid = bidState.GetCheapestShiftBid(nEventualSuit, pDOC->GetLastValidBid()); status << "2GERBY3! so without quite enough points for a slam, we just bid " & BTS(nBid) & ".\n"; } // bidState.SetBid(nBid); return TRUE; } // // else we're playing Gerber and do not hold all four aces // so make the bid to ask for aces // int nPartnersbid = bidState.nPartnersBid; if ((nPartnersbid == BID_1NT) || (nPartnersbid == BID_2NT) // NCR-246a Allow Gerber after Stayman 2C || ((nPartnersbid < BID_3NT) && bidState.nPreviousBid == BID_2C) ) { nBid = BID_4C; status << "GERBD! with " & bidState.fCardPts & "/" & bidState.fPts & "/" & bidState.fAdjPts & " points in the hand, for a total of approx. " & fMinTPCPoints & "-" & fMaxTPCPoints & " / " & fMinTPPoints & "-" & fMaxTPPoints & " pts in the partnership, explore slam possibilities with Gerber at " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "GERBDx! we'd like to use Gerber, but partner has already bid higher than 4C, so we have to pass.\n"; } bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_INVOKED_ROUND1); // done return TRUE; }
// //----------------------------------------------------- // // respond to partner's Jacoby 2NT Bid // BOOL CJacoby2NTConvention::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() != NULL) && (bidState.GetActiveConvention() != this)) return FALSE; // // make a responding bid // int nPartnersBid = bidState.nPartnersBid; int nPreviousBid = bidState.nPreviousBid; int numTotalBidTurns = pDOC->GetNumBidsMade(); // int nBid; double fPts = bidState.fPts; double fCardPts = bidState.fCardPts; // // see what round this is // int nStatus = bidState.GetConventionStatus(this); if (nStatus == CONV_INACTIVE) { // // Bidding in response to partner's Jacoby 2NT bid? // // the requirements for a Jacoby 2NT Bid are: // 1: we must have opened the bidding with 1 of a major // 2: Partner responded with 2NT int nOpeningBid = pDOC->GetOpeningBid(); // test conditions if ( (bidState.m_numBidTurns == 1) && (ISMAJOR(BID_SUIT(nPreviousBid))) && (nOpeningBid == nPreviousBid) && (BID_LEVEL(nPreviousBid) == 1) && (bidState.nPartnersBid == BID_2NT) ) { // passed the test } else { return FALSE; } status << "J2N20! Partner has made a Jacoby 2NT inquiry bid, indicating " & OPEN_PTS(13) & " pts and 4+ card support.\n"; // adjust points as declarer int nSuit = bidState.nPreviousSuit; bidState.SetAgreedSuit(nSuit); fPts = bidState.fAdjPts = hand.RevalueHand(REVALUE_DECLARER, nSuit, TRUE); // partner has 13+ pts bidState.AdjustPartnershipPoints(13, 13); // // our options are as follows, in order: // // - with 18+ pts, rebid the suit at the 3 level // - with 15-17 pts and a strong 5-card side suit, bid that suit at the 4-level // - with 15-17 pts and a short suit, bid the short suit at the 3 level // - with 15-17 pts an no short suit, bid 3NT // - otherwise, sign off in game at the 4-level // check point count if (fPts >= 18) { nBid = MAKEBID(nSuit, 3); status << "J2N21! With " & fPts & " points in hand, " "respond to partner's Jacoby 2NT inquiry with a bid of " & BTS(nBid) & ".\n"; } else if (fPts >= 15) { // see if we have a strong side suit int nSideSuit = NONE; for(int i=0;i<4;i++) { if ((i != nSuit) && (bidState.nSuitStrength[i] <= SS_STRONG) && (bidState.numCardsInSuit[i] >= 5)) break; } // if (i < 4) { // bid the suit at the 4 level nSuit = i; nBid = MAKEBID(nSuit, 4); status << "J2N22! With " & fPts & " points in hand and a good " & bidState.numCardsInSuit[nSuit] & "-card suit in " & STS(nSuit) & ", respond to partner's Jacoby 2NT inquiry with " & BTS(nBid) & ".\n"; } else if (bidState.numVoids >= 1) { // bid the void suit for(nSuit=0;nSuit<4;nSuit++) { if (bidState.numCardsInSuit[nSuit] == 0) break; } nBid = MAKEBID(nSuit, 3); status << "J2N24! With " & fPts & " points in hand and a void suit in " & STS(nSuit) & ", respond to partner's Jacoby 2NT inquiry with a bid of " & BTS(nBid) & ".\n"; } else if (bidState.numSingletons >= 1) { // bid the singleton for(nSuit=0;nSuit<4;nSuit++) { if (bidState.numCardsInSuit[nSuit] == 1) break; } nBid = MAKEBID(nSuit, 3); status << "J2N26! With " & fPts & " points in hand and a singleton in " & STS(nSuit) & ", respond to partner's Jacoby 2NT inquiry with a bid of " & BTS(nBid) & ".\n"; } else { // bid 3NT nBid = BID_3NT; status << "J2N28! With " & fPts & " points in hand and no short suits, " " respond to partner's Jacoby 2NT inquiry with a bid of " & BTS(nBid) & ".\n"; } } else { // sign off at the 4-level nBid = MAKEBID(nSuit, 4); status << "J2N31! With only " & fPts & " points in hand, sign off in game at " & BTS(nBid) & ".\n"; } // and return bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // return FALSE; }
// //========================================================== // // Rebidding as opener after partner responds to an Jacoby 2NT Bid // BOOL CJacoby2NTConvention::HandleConventionResponse(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { // check status if ((bidState.GetConventionStatus(this) != CONV_INVOKED_ROUND1) && (bidState.GetConventionStatus(this) != CONV_INVOKED_ROUND2)) return FALSE; // get some info // int nBid = NONE; int nPrevSuit = bidState.nPartnersPrevSuit; int nSuit = bidState.nPartnersSuit; int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int numSupportCards = bidState.numSupportCards; // // handling partner's Drury response // int nStatus = bidState.GetConventionStatus(this); if (nStatus == CONV_INVOKED) { // // here, our actions depend on partner's response // if (bidState.nPartnersBid == MAKEBID(nPrevSuit, 3)) { // partner responded in the suit at the 3-level, for 18+ pts status << "J2N40! Partner responded to our Jacoby 2NT inquiry by rebidding his " & STSS(nPrevSuit) & " suit at the 3-level, indicating " & OPEN_PTS(18) & "+ points.\n"; // revalue partnership totals bidState.AdjustPartnershipPoints(18, pCurrConvSet->GetValue(tn2ClubOpeningPoints)); } else if ((nPartnersBidLevel == 3) && ISSUIT(nSuit) && (nSuit != nPrevSuit)) { // partner responded in a different suit at the 3-level status << "J2N41! Partner responded to our Jacoby 2NT inquiry by bidding the " & STSS(nSuit) & " suit at the 3-level, indicating " & OPEN_PTS(15) & "-" & OPEN_PTS(17) & " points and a singleton or void in " & STS(nSuit) & ".\n"; // revalue partnership totals bidState.AdjustPartnershipPoints(15, 17); } else if (nPartnersBid == BID_3NT) { // partner responded with 3NT status << "J2N42! Partner responded to our Jacoby 2NT inquiry by bidding 3NT, indicating " & OPEN_PTS(15) & "-" & OPEN_PTS(17) & " points with a balanced hand.\n"; // revalue partnership totals bidState.AdjustPartnershipPoints(15, 17); } else if ((nPartnersBidLevel == 4) && ISSUIT(nSuit) && (nSuit != nPrevSuit)) { // partner responded in a different suit at the 4-level status << "J2N44! Partner responded to our Jacoby 2NT inquiry by bidding the " & STSS(nSuit) & " suit at the 4-level, indicating a strong 5-card side suit and " & OPEN_PTS(15) & "-" & OPEN_PTS(17) & " points in the hand.\n"; // revalue partnership totals bidState.AdjustPartnershipPoints(15, 17); } else if ((nPartnersBidLevel == 4) && (nSuit == nPrevSuit)) { // partner responded in the original suit at the 4-level status << "J2N44! Partner responded to our Jacoby 2NT inquiry by rebidding his " & STSS(nSuit) & " suit at the 4-level, indicating a minimum opener of approx. " & OPEN_PTS(12) & "-" & OPEN_PTS(14) & " points in the hand.\n"; // revalue partnership totals bidState.AdjustPartnershipPoints(12, 14); } else if ((nPartnersBid == BID_DOUBLE) || (nPartnersBid == BID_REDOUBLE)) { // the convention is cancelled! bidState.SetConventionStatus(this, CONV_ERROR); return FALSE; } // now figure out what to do if (bidState.m_fMinTPPoints >= PTS_SLAM) { // go to Blackwood status << "J2N60! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, push on to slam in partner's " & STSS(nPrevSuit) & " suit.\n"; bidState.InvokeBlackwood(nPrevSuit); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } else if (bidState.m_fMinTPPoints >= PTS_MAJOR_GAME) { // we want to bid game if (nPartnersBid < bidState.GetGameBid(nPrevSuit)) { // raise or shift to game nBid = bidState.GetGameBid(nPrevSuit); status << "J2N62! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, go to game in " & STS(nPrevSuit) & " with a bid of " & BTS(nBid) & ".\n"; } else { // here partner bid game or higher -- pass unless it needs correction if (nSuit == nPrevSuit) { nBid = BID_PASS; status << "J2N64! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, pass partner's " & BTS(nPartnersBid) & " bid.\n"; } else { // correct to the original suit nBid = bidState.GetCheapestShiftBid(nPrevSuit, nPartnersBid); status << "J2N66! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, we want to stop at game in " & STS(nPrevSuit) & "; correct partner's " & BTS(nPartnersBid) & " bid to " & BTS(nBid) & ".\n"; } } } else { // oops, caught with too few points // either pass 3NT , or return to the suit at the cheapest level possible if ((nPartnersBid == BID_3NT) || ((nSuit == nPrevSuit))) { nBid = BID_PASS; status << "J2N70! With a total of only " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, we have to stop here at " & BTS(nPartnersBid) & ", so pass.\n"; } else { nBid = bidState.GetCheapestShiftBid(nPrevSuit, nPartnersBid); status << "J2N72! With a total of only " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, we have to return to the " & STSS(nPrevSuit) & " and stop at " & BTS(nBid) & ".\n"; } } // done bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // oops! bidState.SetConventionStatus(this, CONV_ERROR); return FALSE; }
// //========================================================== // // Rebidding as opener after partner responds to a Michaels Cue Bid // BOOL CMichaelsCueBidConvention::HandleConventionResponse(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { // check status if ((bidState.GetConventionStatus(this) != CONV_INVOKED_ROUND1) && (bidState.GetConventionStatus(this) != CONV_INVOKED_ROUND2)) return FALSE; // // get some info // int nBid; double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; double fCardPts = bidState.fCardPts; int nPrefSuit = bidState.nPrefSuit; int nPrefSuitStrength = bidState.nPrefSuitStrength; int nPreviousSuit = bidState.nPreviousSuit; int nPreviousBidLevel = bidState.nPreviousBidLevel; BOOL bBalanced = bidState.bBalanced; // int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPartnersSuit = bidState.nPartnersSuit; int nPartnersSuitSupport = bidState.nPartnersSuitSupport; int nPartnersPrevSuit = bidState.nPartnersPrevSuit; int numSupportCards = bidState.numSupportCards; // // handling partner's Michaels response // int nStatus = bidState.GetConventionStatus(this); if (nStatus == CONV_INVOKED) { // 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); } // if we're holding the STRONG Michaels hand indicate it by cue-bidding the // enemy suit again if (bidState.fPts >= PT_COUNT(17)) { nBid = MAKEBID(nPreviousSuit, 3); status << "MCLRH12! with a strong Michaels hand (" & bidState.fPts & " pts), cue bid the enemy suit again at " & BTS(nBid) & " to indicate our strength.\n"; bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); return TRUE; } // did partner bid 2NT, asking for the minor? if (ISMAJOR(nPreviousSuit) && (nPartnersBid == BID_2NT)) { // with a weak Michaels opener, indicate the minor int nSuit = bidState.GetLongerSuit(CLUBS, DIAMONDS); nBid = MAKEBID(nSuit, 3); status << "MCLRH10! With the weak flavor of Michaels, respond to partner's Michaels minor inquiry with a bid of " & BTS(nBid) & ", indicating " & STS(nSuit) & " as the unknown minor.\n"; bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); return TRUE; } // did partner cue-bid the enemy suit (a slam try)? if ((nPartnersSuit == nPreviousSuit) && (nPartnersBidLevel == nPreviousBidLevel+1)) { // determine the cheapest of the two suits int nCheapestSuit; if (ISMINOR(nPreviousSuit)) nCheapestSuit = HEARTS; // 5/5 in the majors, so Hearts is cheapest else nCheapestSuit = bidState.GetLongerSuit(CLUBS, DIAMONDS); // respond affirmatively only with a strong hand status << "2MCLRH20! Partner cue bid the enemy suit, which is a game or slam try.\n"; if (bidState.fPts >= PT_COUNT(17)) { // jump into Blackwood status << "MCLRH21! And with " & bidState.fPts & " pts in hand, proceed towards slam in the preferred "& STSS(bidState.nPrefSuit) & " suit.\n"; bidState.InvokeBlackwood(bidState.nPrefSuit); } else if ( (ISMAJOR(nCheapestSuit) && (bidState.fPts >= PT_COUNT(9))) || (ISMINOR(nCheapestSuit) && (bidState.fPts >= PT_COUNT(12))) ) { // stop at game in the cheapest suit nBid = bidState.GetGameBid(nCheapestSuit); status << "MCLRH22! But with only " & bidState.fPts & " pts in hand, forget about slam and stop at game in the cheapest suit ("& STS(nCheapestSuit) & ") at " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); } else { // 8 or fewer pts -- bail out in the cheapest suit nBid = bidState.GetCheapestShiftBid(nCheapestSuit); status << "MCLRH23! But with only " & bidState.fPts & " pts in hand, forget about slam and bail out in the cheapest suit (" & STS(nCheapestSuit) & ") at " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); } // done bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // // else partner made a signoff, invitational, or game bid // if (bidState.IsGameBid(nPartnersBid)) { status << "MCLRH30! Partner responded to our Michaels Cue bid with a game bid of " & bidState.szPB & ", so we should pass.\n"; nBid = BID_PASS; } else if (nPartnersBid != BID_PASS) { // see if we should raise partner to game status << "2MCLRH40! Partner responded to our Michaels Cue bid with a bid of " & bidState.szPB & ", a possible invitation to game.\n"; // go to game with 17+ pts (strong hand) if (fPts < PT_COUNT(17)) { nBid = BID_PASS; status << "MCLRH41! But since we opened Michaels with a weak hand (" & fPts & ") pts, we likely do not have the points for game and have to pass.\n"; } else { nBid = bidState.GetGameBid(nPartnersSuit); status << "MCLRH42! and since we opened Michaels with a strong hand (" & fPts & ") pts, we can raise to game at " & BTS(nBid) & ".\n"; } } else { status << "2MCLRH49! Partner passed" & (bidState.bLHOInterfered? "after opponents interference" : "") & ", so Michaels is off.\n"; bidState.SetConventionStatus(this, CONV_FINISHED); return FALSE; } // done bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } else if (nStatus == CONV_INVOKED_ROUND2) { // last time, we either showed our minor suit or indicated our strength // with another cue bid of the opponents' suit // 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); } // did we have the strong hand? if (bidState.fPts >= PT_COUNT(17)) { // see what partner's reaction was if (nPartnersSuit == BID_4NT) { // parter still wants to see our minor!!! int nSuit = bidState.GetLongerSuit(CLUBS, DIAMONDS); nBid = bidState.GetCheapestShiftBid(nSuit); status << "MCLRH50! After our second Michaels cue bid of the enemy suit, partner still wants to see the unknown minor, so show it (" & STS(nSuit) & ") with a bid of " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_INVOKED_ROUND3); return TRUE; } // else partner's bid was natural if (bidState.IsGameBid(nPartnersBid)) { if (fPts < PT_COUNT(20)) { status << "MCLRH55! Partner responded to our second Michaels cue bid with a game bid of " & bidState.szPB & ", so we should pass.\n"; nBid = BID_PASS; } else { // jump to slam nBid = MAKEBID(nPartnersSuit, 6); status << "MCLRH55! Partner responded to our second Michaels cue bid with a game bid of " & bidState.szPB & ", and with " & fPts & "+ in hand, we can go ahead and jump to slam at " & BTS(nBid) & ".\n"; } } else if (nPartnersBid != BID_PASS) { // see if we should raise partner to game nBid = bidState.GetGameBid(nPartnersSuit); status << "MCLRH56! Partner responded to our second Michaels cue bid of the enemy suit with a bid of " & bidState.szPB & ", an invitation to game -- so go ahead and bid game at " & BTS(nBid) & ".\n"; } else { if (bidState.bLHOInterfered) status << "MCLRH58! Partner passed our second Michaels cue bid after interference, so we have to pass also.\n"; else status << "MCLRH59! Partner passed in spite of our second Michaels cue bid, so we should pass also.\n"; nBid = BID_PASS; } } else { // partner responded to our minor answer if (bidState.IsGameBid(nPartnersBid)) { status << "MCLRH60! Partner responded to our Michaels minors answer with a game bid of " & bidState.szPB & ", so we should pass.\n"; nBid = BID_PASS; } else if (nPartnersBid != BID_PASS) { // see if we should raise partner to game status << "MCLRH70! Partner responded to our Michaels minor answer with a bid of " & bidState.szPB & ", a possible invitation to game.\n"; // go to game with 17+ pts (strong hand) if (fPts < PT_COUNT(17)) { nBid = BID_PASS; status << "MCLRH72! But since we opened Michaels with a weak hand (" & fPts & ") pts, we likely do not have the points for game and have to pass.\n"; } else { nBid = bidState.GetGameBid(nPartnersSuit); status << "MCLRH72! and since we opened Michaels with a strong hand (" & fPts & ") pts, we can raise to game at " & BTS(nBid) & ".\n"; } } else { if (bidState.bLHOInterfered) status << "MCLRH75! Partner passed our Michaels minor answer after interference, so we have to pass also.\n"; else status << "MCLRH76! Partner passed our Michaels minor answer, so we should pass also.\n"; nBid = BID_PASS; } } // done bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } else if (nStatus == CONV_INVOKED_ROUND3) { // 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); } // we indicated our strength with another cue bid, and partner asked // to see our minor, _then_ bid if (bidState.IsGameBid(nPartnersBid)) { if (fPts < PT_COUNT(20)) { status << "MCLRH80! Partner responded to our Michaels minor answer with a game bid of " & bidState.szPB & ", so we should pass.\n"; nBid = BID_PASS; } else { // jump to slam nBid = MAKEBID(nPartnersSuit, 6); status << "MCLRH81! Partner responded to our Michaels minor answer with a game bid of " & bidState.szPB & ", and with " & fPts & "+ in hand, we can go ahead and jump to slam at " & BTS(nBid) & ".\n"; } } else if (nPartnersBid != BID_PASS) { // see if we should raise partner to game nBid = bidState.GetGameBid(nPartnersSuit); status << "MCLRH85! Partner responded to our Michaels minor answer with a bid of " & bidState.szPB & ", an invitation to game -- so go ahead and bid game at " & BTS(nBid) & ".\n"; } else { if (bidState.bLHOInterfered) status << "MCLRH86! Partner passed our Michaels minor answer after interference, so we have to pass also.\n"; else status << "MCLRH87! Partner passed in spite of our Michaels minor answer, so we should pass also.\n"; nBid = BID_PASS; } // done (finally!) bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // oops! 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; }
// //=============================================================================== // // RespondToConvention() // // partner bid at the 2-level (strong 2 bid) // // in general, partner's opening 2-bid denotes an extremely // powerful hand. So the question is whether to try for game // or slam. Therefore, we respond positively if we want attempt // a slam, or negatively for game // BOOL CStrongTwoBidsConvention::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()) return FALSE; // // Bidding in response to an opening strong 2 bid? check requirements // int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPartnersSuit = bidState.nPartnersSuit; int nPartnersSuitSupport = bidState.nPartnersSuitSupport; int numSupportCards = bidState.numSupportCards; int numPartnerBidsMade = bidState.m_numPartnerBidsMade; // // // partner must've bid at the 2 level, but not 2C, // and partner's bid must have been the first bid made // if ((nPartnersBidLevel == 2) && (nPartnersBid != BID_2C) && (bidState.m_bPartnerOpenedForTeam) && (numPartnerBidsMade == 1) && (nPartnersBid == pDOC->GetValidBidRecord(0))) { // okay, met requirements } else { // return FALSE; } // int nBid; double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; double fCardPts = bidState.fCardPts; int nPrefSuit = bidState.nPrefSuit; int numPrefSuitCards = bidState.numPrefSuitCards; double numQuickTricks = bidState.numQuickTricks; // state expectations bidState.m_fPartnersMin = 16; bidState.m_fPartnersMax = 22; status << "RSTRT! Partner made a strong 2-bid, showing a very good suit or two solid suits, 9+ playing tricks, and 4+ quick tricks. We have to respond positively if interested in slam, or negatively otherwise.\n"; // set partnership point count minimums & maximums bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; // the bid is forcing to game bidState.m_bGameForceActive = TRUE; // // if we have less than 1 Quick trick, respond negatively // if (numQuickTricks < 1.0) { nBid = BID_2NT; status << "RSTRT10! But with only " & numQuickTricks & " QT's, we have to make the negative response of " & BTS(nBid) & " to deny slam values.\n"; bidState.SetBid(nBid); return TRUE; } // // else we have >= 1 Quick trick, so respond positively // status << "2RSTRT20! We have " & numQuickTricks & " QT's, so we can make a positive response.\n"; // if we have even half-decent support for partner's suit, show it if (nPartnersSuitSupport >= SS_WEAK_SUPPORT) { nBid = MAKEBID(nPartnersSuit,3); status << "RSTRT22! And we have " & bidState.SLTS(nPartnersSuit) & " support for partner's long " & bidState.szPSS & " suit (holding " & bidState.szHP & "), so raise partner's bid to " & BTS(nBid) & ".\n"; } else if ((nPrefSuit != nPartnersSuit) && (bidState.nPrefSuitStrength >= SS_OPENABLE) && (numPrefSuitCards >= 5)) { // or show our own suit if we have a good 5+ suiter int nSuit = nPrefSuit; // jump shift if the suits is really strong if (bidState.nPrefSuitStrength >= SS_ABSOLUTE) { nBid = bidState.GetJumpShiftBid(nSuit,nPartnersBid); status << "RSTRT24! We lack good support for partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & "), but we have an excellent " & bidState.LEN(nSuit) & "-card suit of our own in " & STS(nSuit) & " (holding " & bidState.SHTS(nSuit) & "), so show it in a bid of " & BTS(nBid) & ".\n"; } else { nBid = bidState.GetCheapestShiftBid(nSuit); status << "RSTRT26! But we lack good support for partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & "), so show our preferred " & bidState.LEN(nSuit) & "-card " & STSS(nSuit) & " suit in a bid of " & BTS(nBid) & ".\n"; } } else if ((bidState.bBalanced) && (bidState.m_fMinTPCPoints >= 26)) { // here, we lack good support for partner's suit, and don't have a good // suit of our own. so we jump to 3NT if we have a // balanced hand & 26+ total HCPs nBid = BID_3NT; status << "RSTRT28! But we lack good support for partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & ") with a balanced hand, so jump to " & BTS(nBid) & ".\n"; } else { // here, we don't have good support for partner's // suit, nor a good suit of our own, nor a balanced // hand. So bid 2NT in a negative response. nBid = BID_2NT; status << "RSTRT40! But unfortunately we have poor support for partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & "), no good suit of our own, and an unbalanced hand, so we have to make the negative response of " & BTS(nBid) & ".\n"; } // bidState.SetBid(nBid); return TRUE; }
// //--------------------------------------------------------------- // // 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 // NCR BIG PROBLEM HERE - This changes a global variable. The changes are now always wanted ??? 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; }
// //========================================================== // // Rebidding as opener after a strong 2-level opening // // BOOL CStrongTwoBidsConvention::HandleConventionResponse(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { if (bidState.GetConventionStatus(this) != CONV_INVOKED) return FALSE; bidState.ClearConventionStatus(this); // // estimate partner's strength // int nBid; double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; double fCardPts = bidState.fCardPts; int nPrefSuit = bidState.nPrefSuit; int nPrefSuitStrength = bidState.nPrefSuitStrength; int nPreviousSuit = bidState.nPreviousSuit; int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPartnersSuit = bidState.nPartnersSuit; int nPartnersSuitSupport = bidState.nPartnersSuitSupport; int numSupportCards = bidState.numSupportCards; BOOL bBalanced = bidState.bBalanced; // // did we get a negative response from partner? // if (nPartnersBid == BID_2NT) { status << "2S2Rb0! After our strong " & bidState.szPVB & " opening bid, partner's 2NT bid is a negative response, denying slam values (less than 1 Quick Trick).\n"; // estimate points -- 0 to 6 for now bidState.m_fPartnersMin = 0; bidState.m_fPartnersMax = 6; bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; // after a negative response, bid 3NT if balanced // with 26+ HCPs if ((bBalanced) && (bidState.m_fMinTPCPoints >= PTS_NT_GAME)) { nBid = BID_3NT; status << "S2RB1! With a balanced distribution and " & fCardPts & " HCPs in hand, rebid " & BTS(nBid) & ".\n"; } // else show a second preferred suit if available if (bidState.numPreferredSuits > 0) { int nSuit = bidState.GetRebidSuit(nPreviousSuit); nBid = bidState.GetCheapestShiftBid(nSuit); status << "S2RB4! With a good second suit in " & STS(nSuit) & ", show it in a rebid of " & BTS(nBid) & ".\n"; } // otherwise rebid our original suit (if not 2C) if (bidState.nPreviousBid == BID_2C) { nBid = bidState.GetCheapestShiftBid(nPrefSuit); status << "S2RB6! With no other good suits, go ahead and bid our " & bidState.szPrefS & " suit at " & BTS(nBid) & ".\n"; } else { nBid = bidState.GetCheapestShiftBid(nPreviousSuit); status << "B3E32! With no other good suits, go ahead and rebid our " & bidState.szPVSS & " suit at " & BTS(nBid) & ".\n"; } // bidState.SetBid(nBid); return TRUE; } // // otherwise, got a positive response, and partner has shown // his long suit -- so either raise partner's suit, bid NT, or // rebid our own suit // status << "2S2Rb20! After our strong " & bidState.szPVB & " opening bid, partner's " & bidState.szPB & " bid was a positive response, indicating 1+ Quick Tricks.\n"; // estimate points -- 3+ pts for now bidState.m_fPartnersMin = 3; bidState.m_fPartnersMax = MIN(22, 40 - fCardPts); bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; // bid No Trump if balanced if (bBalanced) { nBid = BID_3NT; status << "With a balanced hand, bid game at " & BTS(nBid) & ".\n"; } // see if there's a suit agreement from a strong 2 bid if ((nPreviousSuit == nPartnersSuit) && (bidState.nLastBid != BID_2C)) { // try for a slam; use Blackwood status << "S2RB24! Partner's encouraging raise to " & bidState.szPB & " indicates 1+ Quick Tricks and slam possibilities.\n"; bidState.InvokeBlackwood(nPartnersSuit); return TRUE; } // raise partner's suit if possible if (nPartnersSuitSupport >= SS_GOOD_SUPPORT) { // double raise partner if major, or go directly to Blackwood // if minor (double raise from 3C or 3D would exceed 4NT if (ISMAJOR(nPartnersSuit)) { bidState.m_nAgreedSuit = nPartnersSuit; nBid = MAKEBID(nPartnersSuit,nPartnersBidLevel+2); status << "S2RB28! With " & bidState.SLTS(nPartnersSuit) & " support for partner's " & bidState.szPS & " (holding " & bidState.szHP & "), go ahead and jump raise to " & BTS(nBid) & ".\n"; } else { status << "S2RB32! We have " & bidState.SLTS(nPartnersSuit) & " support for partner's " & bidState.szPS & " (holding " & bidState.szHP & ").\n"; bidState.InvokeBlackwood(nPartnersSuit); return TRUE; } } // else show a second preferred suit if available if (bidState.numPreferredSuits > 1) { int nSuit = bidState.GetRebidSuit(nPreviousSuit); nBid = bidState.GetCheapestShiftBid(nSuit); status << "S2RB36! But we don't like partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & "), and we hold a good second suit in " & STS(nSuit) & ", so show it in a rebid of " & BTS(nBid) & ".\n"; } // otherwise rebid our original suit (if not 2C) if (bidState.nPreviousBid == BID_2C) { nBid = bidState.GetCheapestShiftBid(nPrefSuit); status << "S2RB44! But we don't like partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & "), so bid our own " & bidState.szPrefS & " suit at " & BTS(nBid) & ".\n"; } else { nBid = bidState.GetCheapestShiftBid(nPreviousSuit); status << "S2RB50! But we don't like partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & "), so rebid our own " & bidState.szPVSS & " suit at " & BTS(nBid) & ".\n"; } // bidState.SetBid(nBid); return TRUE; }
// //=============================================================================== // // TryConvention() // // check if we can open with a preemptive 3 or 4 bid // BOOL CShutoutBidsConvention::TryConvention(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { // basic requirements: no non-pass bid must have been entered yet if (bidState.nLastValidRecordedBid != BID_PASS) return FALSE; // someone else has opened already // //-------------------------------------------------------- // // Now check for a shutout bid of 3 or 4 // // at the very minimum, should have a 6-card suit // if (hand.GetNumSuitsOfAtLeast(6) < 1) return FALSE; // // first find (a) long suit // /* for(i=0;i<4;i++) { if (hand.numCardsInSuit[i] >= 6) { // a 7-card suit needs 2 honors, and a a 6-card suit needs 3 if ( ((hand.GetNumCardsInSuit(i) >= 7) && (hand.GetNumhonorsInSuit(i) >= 2)) || ((hand.GetNumCardsInSuit(i) == 6) && (hand.GetNumhonorsInSuit(i) >= 3)) ) break; } } */ // assume the long suit is the preferred one int nSuit = hand.GetPreferredSuit(); CSuitHoldings& suit = hand.GetSuit(nSuit); int numCards = suit.GetNumCards(); int numHonors = suit.GetNumHonors(); // a 6-card suit needs 3 honors, and a 7+ card suit needs 2 if ( ((numCards == 6) && (numHonors < 3)) || ((numCards >= 7) && (numHonors < 2)) ) return FALSE; // // then check for Aces, Kings, or Queens in outside suits int nBid; BOOL bViolation = FALSE; for(int i=0;i<4;i++) { if (i == nSuit) continue; // a solitary Q is okay for a Shutout bid, but any higher honors // are not CSuitHoldings& suit = hand.GetSuit(i); if (suit.HasAce() || suit.HasKing()) return FALSE; } // if (bidState.numCardsInSuit[nSuit] >= 8) { nBid = MAKEBID(nSuit,4); status << "D00! Have a " & bidState.numCardsInSuit[nSuit] & "-card " & STSS(nSuit) & " suit with no tricks outside the suit, so make a shutout bid of " & BTS(nBid) & ".\n"; } else if (bidState.numCardsInSuit[nSuit] >= 7) { nBid = MAKEBID(nSuit,3); status << "D04! Have a " & bidState.numCardsInSuit[nSuit] & "-card " & STSS(nSuit) & " suit with no tricks outside the suit, so make a shutout bid of " & BTS(nBid) & ".\n"; } bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_INVOKED); return TRUE; }
// //=============================================================================== // // TryConvention() // // check if we can open with a strong two-bid // BOOL CStrongTwoBidsConvention::TryConvention(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { // basic requirements: no non-pass bid must have been entered yet if (bidState.nLastValidRecordedBid != BID_PASS) return FALSE; // someone else has opened already // To open with a strong two bid, we need either a long, very good suit // or 2 string suits, with 9+ playing tricks for majors (10+ for minors) // plus 4 quick tricks. // we also need a _minimum_ of 16 HCPs, no matter what if ( ((bidState.numAbsoluteSuits >= 1) || (bidState.numSolidSuits >= 2)) && (bidState.numLikelyWinners >= 9) && (bidState.numQuickTricks >= 4) && (bidState.fCardPts >= 16)) { // bid 2 of lowest openable solid suit double fPts = bidState.fPts; double fCardPts = bidState.fCardPts; int nBid = bidState.GetLowestOpenableBid(SUITS_ANY, OT_STRONG, 2); if ((nBid == BID_2C) && (pCurrConvSet->IsConventionEnabled(tidArtificial2ClubConvention))) { // we can't open a strong 2C when playing the 2Club convention, // so see if we can find another strong suit int nextBestSuit = bidState.nPrefSuitList[1]; if (bidState.nSuitStrength[nextBestSuit] >= SS_STRONG) { nBid = MAKEBID(nextBestSuit ,2); status << "STR2C1! Have a strong Club suit and " & fPts & " points, but can't open at 2 Club, so we'll have to bid " & STS(nextBestSuit) & " instead.\n"; } else { // can't bid at the 1-level status << "STR2C2! Have a strong Club suit and no others, but can't open 2C with only " & fCardPts & " HCPs, so bid " & BTS(nBid) & " instead.\n"; return FALSE; } } // a biddable suit has been established if (bidState.numSolidSuits > 1) { status << "STR2C10! Have " & bidState.numSolidSuits & " solid " & ((bidState.numSolidSuits>1)? "suits" : "suit") & " with " & bidState.numLikelyWinners & " playing tricks and " & bidState.numQuickTricks & " quick tricks, so bid a strong " & BTS(nBid) & ".\n"; } else { status << "STR2C12! Have a solid " & STSS(bidState.nPrefSuit) & " suit with " & bidState.numLikelyWinners & " playing tricks and " & bidState.numQuickTricks & " quick tricks, so bid a strong " & BTS(nBid) & ".\n"; } bidState.SetBid(nBid); // bidState.SetConventionStatus(this, CONV_INVOKED); return TRUE; } // failed the test return FALSE; }
// //========================================================== // // Rebidding as opener after a strong 2-level opening // // BOOL CArtificial2ClubConvention::HandleConventionResponse(const CPlayer& player, const CConventionSet& conventions, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) { int nStatus = bidState.GetConventionStatus(this); if (nStatus <= 0) return FALSE; // // estimate partner's strength // int nBid; double fPts = bidState.fPts; double fAdjPts = bidState.fAdjPts; double fCardPts = bidState.fCardPts; int nPrefSuit = bidState.nPrefSuit; int nPrefSuitStrength = bidState.nPrefSuitStrength; int nPreviousSuit = bidState.nPreviousSuit; int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPartnersSuit = bidState.nPartnersSuit; int nPartnersSuitSupport = bidState.nPartnersSuitSupport; int numSupportCards = bidState.numSupportCards; BOOL bBalanced = bidState.bBalanced; BOOL bSemiBalanced = bidState.bSemiBalanced; // see if this is our first rebid 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); } // // did we get a negative response? (2D in response to the 2C) // if (nPartnersBid == BID_2D) { status << "CRB0! After our strong 2 Club opening, partner's 2 Diamond bid is a negative response, denying slam values (less than 1 Quick Trick).\n"; // estimate points -- 0 to 6 for now bidState.m_fPartnersMin = 0; bidState.m_fPartnersMax = 6; bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; // bid game or slam with 26+ pts if ((bidState.m_fMinTPCPoints >= PTS_NT_GAME) && (bidState.m_fMinTPCPoints < PTS_SMALL_SLAM)) { if (bBalanced || bSemiBalanced) { nBid = BID_3NT; status << "CRB1! With a balanced distribution and " & fCardPts & " HCPs in hand, rebid " & BTS(nBid) & ".\n"; } else if ( (ISMAJOR(nPrefSuit) && (bidState.m_fMinTPPoints >= PTS_MAJOR_GAME)) || (ISMINOR(nPrefSuit) && (bidState.m_fMinTPPoints >= PTS_MINOR_GAME)) ) { nBid = bidState.GetGameBid(nPrefSuit); status << "CRB2! With no help from partner, we have to unilaterally push on to game at " & BTS(nBid) & ".\n"; } bidState.SetConventionStatus(this, CONV_FINISHED); } else if ((bidState.m_fMinTPCPoints >= PTS_SMALL_SLAM) && (bidState.m_fMinTPCPoints < PTS_GRAND_SLAM)) { if (bBalanced || bSemiBalanced) { nBid = BID_6NT; status << "CRB4! With a balanced distribution and " & fCardPts & " HCPs in hand, bid a slam at " & BTS(nBid) & ".\n"; } else { nBid = MAKEBID(nPrefSuit, 6); status << "CRB5! With no help from partner but with a total of " & bidState.m_fMinTPPoints & " points in the partnership, we have to unilaterally push on to a slam at " & BTS(nBid) & ".\n"; } bidState.SetConventionStatus(this, CONV_FINISHED); } else if (bidState.m_fMinTPCPoints >= PTS_GRAND_SLAM) { if (bBalanced || bSemiBalanced) { nBid = BID_7NT; status << "CRB6! With a balanced distribution and " & fCardPts & " HCPs in hand, bid a grand slam at " & BTS(nBid) & ".\n"; } else { nBid = MAKEBID(nPrefSuit, 7); status << "CRB5! With no help from partner but with a total of " & bidState.m_fMinTPPoints & " points in the partnership, we have to unilaterally push on to a grand slam at " & BTS(nBid) & ".\n"; } bidState.SetConventionStatus(this, CONV_FINISHED); } else { // else show our preferred suit and see if partner bids again nBid = bidState.GetCheapestShiftBid(nPrefSuit); status << "CRB8! Show our strongest suit (" & bidState.szPrefS & ") with a bid of " & BTS(nBid) & ".\n"; bidState.SetConventionStatus(this, CONV_INVOKED_ROUND2); } // bidState.SetBid(nBid); return TRUE; } // // otherwise, we got a positive response, and partner has shown // his long suit -- so either raise partner's suit, bid NT, or // rebid our own suit // status << "2CRB20! After our strong 2 Club opening, partner's " & bidState.szPB & " bid was a positive response, indicating 7+ pts and 1+ Quick Tricks.\n"; // estimate points -- 7+ pts for now bidState.m_fPartnersMin = 7; bidState.m_fPartnersMax = MIN(22, 40 - fCardPts); bidState.m_fMinTPPoints = fAdjPts + bidState.m_fPartnersMin; bidState.m_fMaxTPPoints = fAdjPts + bidState.m_fPartnersMax; bidState.m_fMinTPCPoints = fCardPts + bidState.m_fPartnersMin; bidState.m_fMaxTPCPoints = fCardPts + bidState.m_fPartnersMax; // respond to partner's NT bid here // bid No Trump if reasonably balanced or have poor support if (nPartnersBid == BID_2NT) { if ( bidState.bSemiBalanced || ((nPartnersSuitSupport <= SS_WEAK_SUPPORT) && (bBalanced)) ) { if (bidState.m_fMinTPCPoints >= PTS_SLAM) nBid = BID_6NT; else nBid = BID_3NT; if (ISSUIT(nPartnersSuit)) status << "CRB21! With a balanced hand and " & bidState.SLTS(nPartnersSuit) & " support for partner's " & bidState.szPS & ", plus a total of " & bidState.m_fMinTPCPoints & "-" & bidState.m_fMaxTPCPoints & " HCPs in the partnership, move to Notrump and bid " & ((BID_LEVEL(nBid) >= 6)? "slam" : "game") & " at " & BTS(nBid) & ".\n"; else status << "CRB22! With a " & (!bBalanced? "semi-" : "") & "balanced hand and a total of " & bidState.m_fMinTPCPoints & "-" & bidState.m_fMaxTPCPoints & " HCPs in the partnership, raise partner to " & ((BID_LEVEL(nBid) >= 6)? "slam" : "game") & " at " & BTS(nBid) & ".\n"; } else { // we're not balanced, so show our preferred suit if possible nBid = bidState.GetCheapestShiftBid(nPrefSuit); status << "CRB25! We don't like Notrump, so so bid our " & bidState.szPrefS & " suit at " & BTS(nBid) & ".\n"; } // bidState.SetBid(nBid); return TRUE; } // raise partner's suit if possible if ((nPartnersSuit != NOTRUMP) && (nPartnersSuitSupport >= SS_GOOD_SUPPORT)) { // double raise partner if major, or go directly to Blackwood // if minor (double raise from 3C or 3D would exceed 4NT if (ISMAJOR(nPartnersSuit)) { bidState.m_nAgreedSuit = nPartnersSuit; nBid = bidState.GetGameBid(nPartnersSuit); BOOL bJumped = (nPartnersBidLevel == 2); status << "CRB28! With " & bidState.SLTS(nPartnersSuit) & " support for partner's " & bidState.szPS & " (holding " & bidState.szHP & "), go ahead and " & (bJumped? "jump" : "") & " raise to " & BTS(nBid) & ".\n"; bidState.SetBid(nBid); } else { status << "CRB32! We have " & bidState.SLTS(nPartnersSuit) & " support for partner's " & bidState.szPS & " (holding " & bidState.szHP & "), so push towards slam.\n"; bidState.InvokeBlackwood(nPartnersSuit); bidState.SetConventionStatus(this, CONV_FINISHED); } return TRUE; } // else show our preferred suit nBid = bidState.GetCheapestShiftBid(nPrefSuit); status << "CRB44! But we don't like partner's " & bidState.szPSS & " suit (holding " & bidState.szHP & "), so bid our own " & bidState.szPrefS & " suit at " & BTS(nBid) & ".\n"; // done 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); } // partner bid another suit after our rebid of our suit // AFTER her negative response to our opening strong 2C int nPartnersSuit = bidState.nPartnersSuit; if ((nPartnersSuit != NOTRUMP) && (nPartnersSuit != bidState.nPreviousSuit)) { status << "CRB60! Partner bid " & bidState.szPB & " after we bid our " & bidState.szPVS & " suit, indicating a strong preference for the " & bidState.szPS & " suit.\n"; // support partner's suit if we have decent holdings, else bid our own suit if (bidState.nPartnersBid < bidState.GetGameBid(nPartnersSuit)) { // see if we like partner's suit if (bidState.nPartnersSuitSupport >= SS_GOOD_SUPPORT) { nBid = bidState.GetGameBid(nPartnersSuit); status << "CRB62! So with " & bidState.SLTS(nPartnersSuitSupport) & " support for partner's " & bidState.szPS & ", raise to game at " & BTS(nBid) & ".\n"; } else { nBid = bidState.GetCheapestShiftBid(bidState.nPreviousSuit); status << "CRB62! But with only " & bidState.SLTS(nPartnersSuitSupport) & " support for partner's " & bidState.szPS & ", return to our own suit at " & BTS(nBid) & ".\n"; } } else { // partner bid game! if (bidState.m_fMinTPPoints < PTS_SLAM) { // we don't have points for a slam, so pass nBid = BID_PASS; if (bidState.nPartnersBidLevel < 6) status << "CRB68! Partner's " & bidState.szPB & " bid is at game level, so pass.\n"; else status << "CRB69! Partner's " & bidState.szPB & " bid is at slam level, so pass.\n"; } else { // we do have the points for a slam! if (bidState.nPartnersBidLevel < 6) { nBid = BID_6NT; status << "CRB72! While we do not have suit agreement, we have the points for a slam, so bid " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "CRB74! Partner has bid slam in his suit, so pass.\n"; } } } } else if (nPartnersSuit == NOTRUMP) { // partner bid NT // bid 3NT if possible if ( bidState.bSemiBalanced || ((nPartnersSuitSupport <= SS_WEAK_SUPPORT) && (bBalanced)) ) { if (bidState.m_fMinTPCPoints >= PTS_SLAM) nBid = BID_6NT; else nBid = BID_3NT; if (ISSUIT(nPartnersSuit)) status << "CRB76! With a balanced hand and " & bidState.m_fMinTPCPoints & "-" & bidState.m_fMaxTPCPoints & " HCPs in the partnership, respond at " & ((BID_LEVEL(nBid) >= 6)? "slam" : "game") & " with a bid of " & BTS(nBid) & ".\n"; else status << "CRB77! With a " & (!bBalanced? "semi-" : "") & "balanced hand and a total of " & bidState.m_fMinTPCPoints & "-" & bidState.m_fMaxTPCPoints & " HCPs in the partnership, raise partner to " & ((BID_LEVEL(nBid) >= 6)? "slam" : "game") & " at " & BTS(nBid) & ".\n"; } else { // we're not balanced, so show our preferred suit if possible nBid = bidState.GetCheapestShiftBid(nPrefSuit); status << "CRB78! We don't like Notrump, so so bid our " & bidState.szPrefS & " suit at " & BTS(nBid) & ".\n"; } // bidState.SetBid(nBid); return TRUE; } else { // partner raised, which is strange! status << "CRB80! Partner raised our " & bidState.szPVSS & " suit, which is strange, "; if (bidState.nPartnersBid < bidState.GetGameBid(nPartnersSuit)) { nBid = bidState.GetGameBid(bidState.nPartnersSuit); status << "but go ahead and raise to game."; } else { nBid = BID_PASS; status << "but since we're at game, stop here and pass.\n"; } } // and we're done bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } // shouldn't be here! return FALSE; }
// // OnCommand() // BOOL CBidDialogSmall::OnCommand(WPARAM wParam, LPARAM lParam) { int nID = LOWORD(wParam); int nCode = HIWORD(wParam); int nMessageType = wParam; int nBid; // // Respond to a button press // if (wParam == WMS_BIDDING_RESTART) { OnBidRestart(); return TRUE; } // if (wParam == WMS_FLASH_BUTTON) { FlashButton(lParam); return TRUE; } // check for bid level press if ((nCode == BN_CLICKED) && (nID >= IDC_BID_LEVEL_1) && (nID <= IDC_BID_LEVEL_7)) { // check current mode if ((m_nCurrMode != BD_MODE_WAITFORBID) && (m_nCurrMode != BD_MODE_MANUAL_BID)) return TRUE; // m_nSelectedLevel = nID - IDC_BID_LEVEL_1 + 1; // enable/disable buttons EnableControls(); // highlight the level ((CButton*)GetDlgItem(nID))->SetState(TRUE); // DisableControls(); // return TRUE; } // check for bid suit press if ((nCode == BN_CLICKED) && (nID >= IDC_SUIT_CLUBS) && (nID <= IDC_SUIT_NOTRUMP) ) { // check current mode if ((m_nCurrMode != BD_MODE_WAITFORBID) && (m_nCurrMode != BD_MODE_MANUAL_BID)) return TRUE; // int nSelectedSuit = nID - IDC_SUIT_CLUBS; int nBid = MAKEBID(nSelectedSuit, m_nSelectedLevel); if (m_nCurrMode == BD_MODE_MANUAL_BID) { // record the bid int nPos = pDOC->GetCurrentPlayerPosition(); if (nPos == SOUTH) pDOC->GetCurrentPlayer()->EnterHumanBid(nBid); int nCode = pDOC->EnterBid(nPos, nBid); UpdateBidDisplay(nPos, nBid); // and check the result of the bid ProcessBidReturnCode(nCode); if (nCode == 0) { // bid entered OK, move on to the next player int nPos = pDOC->GetCurrentPlayerPosition(); GetComputerBids(nPos); } } else { RegisterBid(nBid); } return TRUE; } // check for double/redouble if ( (nID == IDC_BID_DOUBLE) || (nID == IDC_BID_REDOUBLE) ) { if (nID == IDC_BID_DOUBLE) nBid = BID_DOUBLE; else if (nID == IDC_BID_REDOUBLE) nBid = BID_REDOUBLE; else nBid = nID - IDC_BID_PASS; // RegisterBid(nBid); return TRUE; } // return CBidDialog::OnCommand(wParam, lParam); }
// //--------------------------------------------------------- // BOOL CEasyBDoc::ReadFile(CArchive& ar) { int i,nRtnCode,nLineCode,nSectionCode; int nIndex,nValue,nOffset,nLen; int nPlayOffset, nPos; int nBidIndex = 0; CString strMessage,string,partString; CCard* pCard; double fValue; BOOL bValue; BOOL bFileInfoFound = FALSE; // read m_nLineNumber = 0; try { for(;;) { nRtnCode = ReadLine(ar, strBuf); next: if (nRtnCode == EOF) break; if (nRtnCode == 0) continue; if ((strBuf[0] == '#') || (strBuf[0] == '*')) continue; nLineLen = nRtnCode; nLineCode = ParseLine(strBuf,nLineLen); if (nLineCode < 0) { // section signifier nSectionCode = -nLineCode; if (nSectionCode == BLOCK_FILEINFO) { // bFileInfoFound = TRUE; // file info; skip this section do { nRtnCode = ReadLine(ar, strBuf); } while ((nRtnCode != EOF) && (strBuf.Left(2) != "[[")); // goto next; } // if (nSectionCode == BLOCK_FILEDESC) { // file description; read until next block m_strFileDescription.Empty(); do { nRtnCode = ReadLine(ar, strBuf); if (strBuf.Left(2) != "[[") { strBuf += "\r\n"; m_strFileDescription += strBuf; } } while ((nRtnCode != EOF) && (strBuf.Left(2) != "[[")); // trim ending CR/LF int nLen = m_strFileDescription.GetLength(); if ((nLen >= 2) && (m_strFileDescription[nLen-1] == _T('\n'))) m_strFileDescription = m_strFileDescription.Left(nLen-2); // goto next; } else if (nSectionCode == BLOCK_COMMENTS) { // file comments for (;;) { nRtnCode = ReadLine(ar, strBuf); if ((nRtnCode == EOF) || (strBuf.Left(2) == "[[")) { // update file comments dialog if it's open CWnd* pWnd = pMAINFRAME->GetDialog(twFileCommentsDialog); if (pWnd) pWnd->SendMessage(WM_COMMAND, WMS_UPDATE_TEXT, FALSE); goto next; } strBuf += "\r\n"; m_strFileComments += strBuf; } } else if ((nSectionCode == BLOCK_SOUTH_ANALYSIS) || (nSectionCode == BLOCK_WEST_ANALYSIS) || (nSectionCode == BLOCK_NORTH_ANALYSIS) || (nSectionCode == BLOCK_EAST_ANALYSIS)) { // don't bother to save the analysis int nPlayer = nSectionCode - BLOCK_SOUTH_ANALYSIS; CString strAnalysisBiffer; do { nRtnCode = ReadLine(ar, strBuf); // strBuf += "\r\n"; // strAnalysisBiffer += strBuf; } while ((nRtnCode != EOF) && (strBuf.Left(2) != "[[")); // m_player[nPlayer].SetValueString(tszAnalysis, strAnalysisBiffer); goto next; } } else if (nLineCode > 0) { // first skip spaces nLen = strBuf.GetLength(); while ((nDataPosition < nLen) && (strBuf[nDataPosition] == ' ')) nDataPosition++; if (nDataPosition >= nLen) continue; // then get data item string = strBuf.Mid(nDataPosition); nValue = atoi(string); fValue = atof(string); if ((string == "Yes") || (string == "1")) bValue = TRUE; else bValue = FALSE; switch(nLineCode) { case ITEM_PROGRAM_ID: m_strFileProgTitle = string; break; case ITEM_MAJOR_VERSIONNO: m_nFileProgMajorVersion = nValue; break; case ITEM_MINOR_VERSIONNO: m_nFileProgMinorVersion = nValue; break; case ITEM_INCREMENT_VERSIONNO: m_nFileProgIncrementVersion = nValue; break; case ITEM_BUILD_NUMBER: m_nFileProgBuildNumber = nValue; break; case ITEM_BUILD_DATE: m_strFileProgBuildDate = string; break; case ITEM_FILE_DATE: m_strFileDate = string; break; // hand info, 10..19 case ITEM_CURRHAND_NORTH: AssignCards(string,NORTH); break; case ITEM_CURRHAND_EAST: AssignCards(string,EAST); break; case ITEM_CURRHAND_SOUTH: AssignCards(string,SOUTH); break; case ITEM_CURRHAND_WEST: AssignCards(string,WEST); break; case ITEM_ORIGHAND_NORTH: AssignCards(string,NORTH,TRUE); break; case ITEM_ORIGHAND_EAST: AssignCards(string,EAST,TRUE); break; case ITEM_ORIGHAND_SOUTH: AssignCards(string,SOUTH,TRUE); break; case ITEM_ORIGHAND_WEST: AssignCards(string,WEST,TRUE); break; // current round info case ITEM_CURR_ROUND_LEAD: m_nRoundLead = StringToPosition(string); break; case ITEM_NUM_CARDS_PLAYED_IN_ROUND: m_numCardsPlayedInRound = nValue; break; case ITEM_TRICK_CARD_1: m_pCurrTrick[0] = deck.GetCard(string); break; case ITEM_TRICK_CARD_2: m_pCurrTrick[1] = deck.GetCard(string); break; case ITEM_TRICK_CARD_3: m_pCurrTrick[2] = deck.GetCard(string); break; case ITEM_TRICK_CARD_4: m_pCurrTrick[3] = deck.GetCard(string); break; // game status info case ITEM_VIEW_STATUS_CODE: pVIEW->SetCurrentMode((CEasyBView::ScreenMode)nValue); break; case ITEM_RUBBER_IN_PROGRESS: theApp.SetValue(tbRubberInProgress, bValue); break; case ITEM_GAME_IN_PROGRESS: // TEMP // theApp.SetValue(tbGameInProgress, FALSE); theApp.SetValue(tbGameInProgress, bValue); break; case ITEM_BIDDING_IN_PROGRESS: theApp.SetValue(tbBiddingInProgress, bValue); break; case ITEM_HANDS_DEALT: m_bHandsDealt = bValue; break; case ITEM_CONTRACT_SUIT: nLen = string.GetLength(); m_nContractSuit = CharToSuit(string.GetAt(0)); break; case ITEM_CONTRACT_LEVEL: m_nContractLevel = nValue; break; case ITEM_CONTRACT_MODIFIER: switch(nValue) { case 0: m_bDoubled = FALSE; m_bRedoubled = FALSE; m_nContractModifier = 0; break; case 1: m_bDoubled = TRUE; m_bRedoubled = FALSE; m_nContractModifier = 1; break; case 2: m_bDoubled = FALSE; m_bRedoubled = TRUE; m_nContractModifier = 2; break; } break; case ITEM_DEALER: m_nDealer = StringToPosition(string); break; case ITEM_NUM_BIDS: // m_numBidsMade = nValue; break; case ITEM_BIDDING_HISTORY: strBiddingHistory = string; break; case ITEM_DECLARER: m_nDeclarer = StringToPosition(string); m_nContractTeam = GetPlayerTeam(m_nDeclarer); m_nDefendingTeam = (m_nContractTeam == NORTH_SOUTH)? EAST_WEST : NORTH_SOUTH; break; // game record case ITEM_NUM_TRICKS_PLAYED: m_numTricksPlayed = nValue; break; case ITEM_NUM_TRICKS_WON_NS: m_numTricksWon[0] = nValue; break; case ITEM_NUM_TRICKS_WON_EW: m_numTricksWon[1] = nValue; break; case ITEM_GAME_LEAD: m_nGameLead = StringToPosition(string); break; case ITEM_GAME_TRICK_1: case ITEM_GAME_TRICK_2: case ITEM_GAME_TRICK_3: case ITEM_GAME_TRICK_4: case ITEM_GAME_TRICK_5: case ITEM_GAME_TRICK_6: case ITEM_GAME_TRICK_7: case ITEM_GAME_TRICK_8: case ITEM_GAME_TRICK_9: case ITEM_GAME_TRICK_10: case ITEM_GAME_TRICK_11: case ITEM_GAME_TRICK_12: case ITEM_GAME_TRICK_13: try { nIndex = nLineCode - ITEM_GAME_TRICK_1; nOffset = 0; nLen = string.GetLength(); // first read the lead player for the trick partString = string.Mid(nOffset); m_nTrickLead[nIndex] = StringToPosition(partString); nOffset = string.Find(' '); // for(i=0;i<4;i++) { while((nOffset < nLen) && (string[nOffset] == ' ')) nOffset++; partString = string.Mid(nOffset); nOffset += 2; if (partString.IsEmpty()) { strMessage.Format("Incomplete Trick record at line %d;\n%s", m_nLineNumber, string); AfxMessageBox(strMessage); break; } // if (partString.Left(2) == "--") { m_pGameTrick[nIndex][i] = NULL; } else { pCard = deck.GetCard(partString); m_pGameTrick[nIndex][i] = pCard; } } // insert the trick record into the game record // in the proper order nPlayOffset = nIndex * 4; nPos = m_nTrickLead[nIndex]; for(i=0;i<4;i++) { CCard* pCard = m_pGameTrick[nIndex][nPos]; if (pCard) m_nPlayRecord[nPlayOffset+i] = pCard->GetDeckValue(); nPos = GetNextPlayer(nPos); } // and finally read the trick's winner while((nOffset < nLen) && (string[nOffset] == ' ')) nOffset++; partString = string.Mid(nOffset); m_nTrickWinner[nIndex] = StringToPosition(partString); } catch(...) { // error } break; // match info case ITEM_SCORE_NS_BONUS: m_nBonusScore[NORTH_SOUTH] = nValue; break; case ITEM_SCORE_NS_GAME0: m_nGameScore[0][NORTH_SOUTH] = nValue; break; case ITEM_SCORE_NS_GAME1: m_nGameScore[1][NORTH_SOUTH] = nValue; break; case ITEM_SCORE_NS_GAME2: m_nGameScore[2][NORTH_SOUTH] = nValue; break; case ITEM_SCORE_NS_GAMES_WON: m_numGamesWon[NORTH_SOUTH] = nValue; break; case ITEM_SCORE_EW_BONUS: m_nBonusScore[EAST_WEST] = nValue; break; case ITEM_SCORE_EW_GAME0: m_nGameScore[0][EAST_WEST] = nValue; break; case ITEM_SCORE_EW_GAME1: m_nGameScore[1][EAST_WEST] = nValue; break; case ITEM_SCORE_EW_GAME2: m_nGameScore[2][EAST_WEST] = nValue; break; case ITEM_SCORE_EW_GAMES_WON: m_numGamesWon[EAST_WEST] = nValue; break; case ITEM_CURRENT_GAME_INDEX: m_nCurrGame = nValue-1; break; case ITEM_BONUS_SCORE_RECORD: m_strArrayBonusPointsRecord.Add(StripQuotes(string)); break; case ITEM_GAME_SCORE_RECORD: m_strArrayTrickPointsRecord.Add(StripQuotes(string)); break; // misc info case ITEM_AUTOSHOW_COMMENTS: m_bShowCommentsUponOpen = bValue; break; case ITEM_AUTOSHOW_BID_HISTORY: m_bShowBidHistoryUponOpen = bValue; break; case ITEM_AUTOSHOW_PLAY_HISTORY: m_bShowPlayHistoryUponOpen = bValue; break; case ITEM_AUTOSHOW_ANALYSES: m_bShowAnalysesUponOpen = bValue; break; } } else { /* // unknown line strMessage.Format("Found Unknown line\n%s.\nContinue?",strBuf); if (AfxMessageBox(strMessage, MB_ICONEXCLAMATION | MB_OKCANCEL) == IDCANCEL) break; */ } } } catch(...) { // handle any improper file error here ClearAllInfo(); // AfxMessageBox("An error ocurred while reading the game file."); return FALSE; } // see if this was a valid file if (!bFileInfoFound) { AfxMessageBox("This is not a proper Easy Bridge game file."); AfxThrowFileException(CFileException::generic); } // // do some sanity checks // m_nContract = MAKEBID(m_nContractSuit, m_nContractLevel); if (!ISPLAYER(m_nDeclarer) || !ISBID(m_nContract)) theApp.SetValue(tbGameInProgress, FALSE); // // parse the bidding history // if (!ISPLAYER(m_nDeclarer)) m_nDeclarer = SOUTH; nPos = m_nDeclarer; m_nCurrPlayer = nPos; int nTeam = GetPlayerTeam(nPos); nOffset = 0; // nLen = strBiddingHistory.GetLength(); for(i=0;;i++) { // skip leading spaces while((nOffset < nLen) && (strBiddingHistory[nOffset] == ' ')) nOffset++; if (nOffset >= nLen) break; // grab the next bid partString = strBiddingHistory.Mid(nOffset); int nBid = ContractStringToBid(partString); // and record it m_nBiddingHistory[m_numBidsMade] = nBid; m_numBidsMade++; m_nCurrPlayer = GetNextPlayer(m_nCurrPlayer); int nBiddingRound = i % 4; m_nBidsByPlayer[nPos][nBiddingRound] = nBid; // see if this is an actual numeric bid if (ISBID(nBid)) { m_nValidBidHistory[m_numValidBidsMade] = nBid; m_numValidBidsMade++; m_nLastValidBid = nBid; m_nLastValidBidTeam = nTeam; } // skip over remainder of current bid string while((nOffset < nLen) && (strBiddingHistory[nOffset] != ' ')) nOffset++; // and move to the next player nPos = GetNextPlayer(nPos); nTeam = GetOpposingTeam(nTeam); } if (ISBID(m_nContract)) UpdateBiddingHistory(); // tally some figures m_nTotalScore[0] = m_nGameScore[0][0] + m_nGameScore[1][0] + m_nGameScore[2][0] + m_nBonusScore[0]; m_nTotalScore[1] = m_nGameScore[0][1] + m_nGameScore[1][1] + m_nGameScore[2][1] + m_nBonusScore[1]; // vulnerability if ((m_numGamesWon[0] > 0) && (m_numGamesWon[1] > 0)) { m_nVulnerableTeam = BOTH; m_bVulnerable[0] = m_bVulnerable[1] = TRUE; } else if (m_numGamesWon[0] > 0) { m_nVulnerableTeam = NORTH_SOUTH; m_bVulnerable[0] = TRUE; } else if (m_numGamesWon[1] > 0) { m_nVulnerableTeam = EAST_WEST; m_bVulnerable[1] = TRUE; } else { m_nVulnerableTeam = NEITHER; } // // set contract info // m_nContract = ContractParamsToBid(m_nContractSuit,m_nContractLevel); m_nTrumpSuit = m_nContractSuit; m_nBiddingRound = nBidIndex; // set play info if (ISBID(m_nContract) && ISPLAYER(m_nDeclarer)) { // contract has been reached m_nDummy = GetPartner((int) m_nDeclarer); m_nGameLead = GetNextPlayer(m_nDeclarer); m_nRoundLead = m_nGameLead; m_nCurrPlayer = m_nRoundLead; m_nTrickLead[0] = m_nRoundLead; // m_pPlayer[m_nDummy]->SetDummyFlag(TRUE); // m_pPlayer[m_nDeclarer]->SetDeclarerFlag(TRUE); } else { // contract has NOT been reached, so restart m_nCurrPlayer = m_nDealer; m_numBidsMade = 0; } // restore initial hands (temp?) for(i=0;i<4;i++) m_pPlayer[i]->RestoreInitialHand(); // not reviewing game m_bReviewingGame = FALSE; // all done return TRUE; }
// //----------------------------------------------------- // // respond to partner's Michaels Cue Bid // BOOL CMichaelsCueBidConvention::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() != NULL) && (bidState.GetActiveConvention() != this)) return FALSE; // // make a responding bid // int nPartnersBid = bidState.nPartnersBid; int nPartnersBidLevel = bidState.nPartnersBidLevel; int nPartnersSuit = bidState.nPartnersSuit; int nPartnersPrevSuit = bidState.nPartnersPrevSuit; // int nBid, nSuit; double fPts = bidState.fPts; double fCardPts = bidState.fCardPts; // // see what round this is // int nStatus = bidState.GetConventionStatus(this); if (nStatus == CONV_INACTIVE) { // // Bidding in response to partner's Michael's bid? check requirements // // the identifying marks of a Michaels bid are: // 1: we must not have bid yet // 2: LHO must have bid a suit at the 1 level, and // 3: partner overcalled LHO's suit at the 2 level int nLastValidBid = pDOC->GetLastValidBid(); // apply tests #1, 2, and 3 int nOpeningBid = pDOC->GetOpeningBid(); int nOpeningBidder = pDOC->GetOpeningBidder(); BOOL bLHOMajor = ISMAJOR(nOpeningBid); if (ISBID(nOpeningBid) && (GetPlayerTeam(nOpeningBidder) != player.GetTeam()) && ((nOpeningBid >= BID_1C) && (nOpeningBid <= BID_1S)) && (nPartnersSuit == bidState.nLHOSuit) && (nPartnersBidLevel == 2) && (bidState.m_numBidsMade == 0) ) { // status << "MCLR10! Partner has made a Michaels Cue bid of " & BTS(nPartnersBid) & ", indicating 5/5 length in " & (bLHOMajor? ((bidState.nLHOSuit == HEARTS)? "Spades and a minor" : "Hearts and a minor") : "the majors") & ".\n"; } else { return FALSE; } // did partner bid a minor, indicating both majors? if (ISMINOR(nPartnersSuit)) { // Pard has both majors -- pick the preferred one nSuit = bidState.PickSuperiorSuit(HEARTS, SPADES); if (hand.GetNumCardsInSuit(nSuit) < 3) { // should have at least 3 trumps int nOtherSuit = (nSuit == HEARTS)? SPADES : HEARTS; if (hand.GetNumCardsInSuit(nOtherSuit) >= 3) nSuit = nOtherSuit; } } else if (nPartnersSuit == HEARTS) { // pard has Spades + a minor // see if Spades are decent (3-card support) // if ((hand.GetNumCardsInSuit(SPADES) >= 3) && (hand.GetSuitStrength(SPADES) >= SS_MODERATE_SUPPORT)) if (hand.GetNumCardsInSuit(SPADES) >= 3) { // fine, go with Spades nSuit = SPADES; } else { // Spades are too weak; look for a minor if ((hand.GetSuitStrength(CLUBS) >= SS_MODERATE_SUPPORT) || (hand.GetSuitStrength(DIAMONDS) >= SS_MODERATE_SUPPORT)) nSuit = NOTRUMP; else nSuit = SPADES; // minors are no good either, so go with Spades } } else { // pard has Hearts + a minor // see if Hearts are decent (3-card support) // if ((hand.GetNumCardsInSuit(HEARTS) >= 3) && (hand.GetSuitStrength(HEARTS) >= SS_MODERATE_SUPPORT)) if (hand.GetNumCardsInSuit(HEARTS) >= 3) { // fine, go with Hearts nSuit = HEARTS; } else { // Spades are too weak; look for a minor if ((hand.GetSuitStrength(CLUBS) >= SS_MODERATE_SUPPORT) || (hand.GetSuitStrength(DIAMONDS) >= SS_MODERATE_SUPPORT)) nSuit = NOTRUMP; else nSuit = HEARTS; // minors are no good either, so go with Hearts } } // now adjust point count if (ISSUIT(nSuit)) { bidState.SetAgreedSuit(nSuit); fPts = bidState.fAdjPts = hand.RevalueHand(REVALUE_DECLARER, nSuit, TRUE); } // partner may have 6-11 OR 17+ pts; assume it's a weak hand bidState.AdjustPartnershipPoints(6, 11); // and make a responding bid CString strChoices = ISMINOR(nPartnersSuit)? "the two majors" : (nPartnersSuit == HEARTS)? "Spades and a minor" : "Hearts and an unknown minor"; int numTrumps = ISSUIT(nSuit)? hand.GetNumCardsInSuit(nSuit) : 0; // set initial convention status to finished bidState.SetConventionStatus(this, CONV_FINISHED); // see if we need to look at the minor if (nSuit == NOTRUMP) { // bid 2NT to ask for the minor nBid = BID_2NT; if (nBid > nLastValidBid) { if (nPartnersSuit == HEARTS) status << "MCLR12! Given a choice between a " & hand.GetNumCardsInSuit(SPADES) & "-card Spade suit and an unknown minor, we're forced to ask for the minor by bidding " & BTS(nBid) & ".\n"; else status << "MCLR12! Given a choice between a " & hand.GetNumCardsInSuit(HEARTS) & "-card Heart suit and an unknown minor, we're forced to ask for the minor by bidding " & BTS(nBid) & ".\n"; // this convention will go another round bidState.SetConventionStatus(this, CONV_RESPONDED_ROUND1); } else { nBid = BID_PASS; status << "MCLR13! We'd like to bid 2NT to ask for partner's minor, but we can't do so after RHO's interference, so we have to pass.\n"; } } else if ((numTrumps >= 5) && (bidState.m_fMinTPPoints <= PT_COUNT(20)) && ISMAJOR(nSuit) && (MAKEBID(nSuit, 4) > nLastValidBid)) { // make a preemptive bid if possible nBid = MAKEBID(nSuit, 4); status << "MCLR15! With " & numTrumps & " " & STS(nSuit) & " and a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, make a shutout bid in " & STS(nSuit) & " by jumping to " & BTS(nBid) & ".\n"; } else if (bidState.m_fMinTPPoints <= PT_COUNT(21)) { // respond at the 2-level nBid = bidState.GetCheapestShiftBid(nSuit, nLastValidBid); if (BID_LEVEL(nBid) == 2) { status << "MCLR20! Given a choice between " & strChoices & ", respond to partner's Michaels with the preferred " & STSS(nSuit) & " suit with a bid of " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "MCLR21! After RHO interference, we don't have the points to go to the 3-level in response to partner's Michaels, so pass.\n"; } } else if (bidState.m_fMinTPPoints <= PT_COUNT(24)) { // bid at the 3-level nBid = MAKEBID(nSuit, 3); if (nBid > nLastValidBid) { status << "MCLR24! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership and a choice between " & strChoices & ", invite game in " & STS(nSuit) & " by jumping to " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "MCLR25! After RHO interference, we don't have the points to go to the 4-level in response to partner's Michaels, so pass.\n"; } } else if (ISMINOR(nSuit) && (bidState.m_fMinTPPoints <= PT_COUNT(27))) { // with 25+ pts, bid game nBid = bidState.GetGameBid(nSuit); if (nBid > nLastValidBid) { status << "MCLR27! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership and a choice between " & strChoices & ", jump to the 4-level in " & STS(nSuit) & " with a bid of " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "MCLR28! After RHO interference, we don't have the points to go to the 5-level in response to partner's Michaels, so pass.\n"; } } else { // with 25+ pts in a major, or 28+ pts in a minor, bid game nBid = bidState.GetGameBid(nSuit); if (nBid > nLastValidBid) { status << "MCLR30! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership and a choice between " & strChoices & ", jump to game in " & STS(nSuit) & " at " & BTS(nBid) & ".\n"; } else { nBid = BID_PASS; status << "MCLR31! After RHO interference, we don't want to bid past game, so pass.\n"; } } // done! bidState.SetBid(nBid); return TRUE; } else if (nStatus == CONV_RESPONDED_ROUND1) { // // round 2 -- we must've bid 2NT last time to ask for partner's minor // // see if partner cue bid the enemy suit again if (nPartnersSuit == nPartnersPrevSuit) { // partner has 17+ pts bidState.AdjustPartnershipPoints(OPEN_PTS(17), MIN(17,40 - bidState.fCardPts)); // bid 4NT to ask for the minor again if (fPts >= PT_COUNT(15)) { // else make a natural game bid nBid = BID_4NT; status << "MCLR35! Partner cue bid the enemy suit again, indicating a strong Michaels opening hand with " & OPEN_PTS(17) & "+ pts; so with " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, ask for the other minor by bidding " & BTS(nBid) & ".\n"; bidState.SetConventionStatus(this, CONV_RESPONDED_ROUND2); } else { // else make a natural 3NT game bid nBid = BID_3NT; status << "MCLR36! Partner cue bid the enemy suit again, indicating a strong Michaels opening hand with " & OPEN_PTS(17) & "+ pts; but with " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, stop at game with a natural bid of " & BTS(nBid) & ".\n"; bidState.SetConventionStatus(this, CONV_FINISHED); } // done bidState.SetBid(nBid); return TRUE; } // see if partner's bid is valid if (!ISMINOR(nPartnersSuit)) { status << "MCLR40! After his opening Michaels Cue Bid, partner did not respond properly to our 2NT minor suit inquiry, so michaels is off.\n"; bidState.SetConventionStatus(this, CONV_ERROR); return FALSE; } // see if we can live with partner's minor int nAgreedSuit; if (hand.GetNumCardsInSuit(nPartnersSuit) >= 3) { // stick with the minor status << "4MCLR41! Since we have " & hand.GetNumCardsInSuit(nPartnersSuit) & " cards in the " & STSS(nPartnersSuit) & " suit, choose that suit for our response.\n"; nAgreedSuit = nPartnersSuit; } else { // minor's not so great; select the better of the minor or the major nAgreedSuit = bidState.PickSuperiorSuit(nPartnersSuit, bidState.nPartnersPrevSuit); if (nAgreedSuit == nPartnersSuit) status << "4MCLR42! The " & STSS(nPartnersSuit) & " suit isn't great, but it's better than " & STS(bidState.nPartnersPrevSuit) & ", so choose that suit for our response.\n"; else status << "4MCLR43! The " & STSS(nPartnersSuit) & " suit is poor, so pick the major suit ("& STS(bidState.nPartnersPrevSuit) & ") for our response.\n"; bidState.SetAgreedSuit(bidState.PickSuperiorSuit(nPartnersSuit, bidState.nPartnersPrevSuit)); } // recalc points as dummy bidState.SetAgreedSuit(nAgreedSuit); fPts = bidState.fAdjPts = hand.RevalueHand(REVALUE_DECLARER, nAgreedSuit, TRUE); bidState.AdjustPartnershipPoints(); // select the bid level if (ISMINOR(nAgreedSuit)) { // Clubs or Diamonds if (bidState.m_fMinTPPoints <= PTS_MINOR_GAME-6) // <= 22 nBid = BID_PASS; else if (bidState.m_fMinTPPoints <= PTS_MINOR_GAME-4) // <= 24 nBid = MAKEBID(nPartnersBid, 4); else nBid = MAKEBID(nPartnersBid, 5); // go for game // if (nBid == BID_PASS) status << "MCLR45! Partner showed his minor to be " & STS(nPartnersSuit) & ", which we can support with " & hand.GetNumCardsInSuit(nPartnersSuit) & " trumps, but with only " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, we have to pass.\n"; else status << "MCLR46! Partner showed his minor to be " & STS(nPartnersSuit) & ", which we can support with " & hand.GetNumCardsInSuit(nPartnersSuit) & " trumps, so with " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, we bid " & BTS(nBid) & ".\n"; } else { // sticking with the major (though not a very good one!) // sign off at the 3-level or go to game if (bidState.m_fMinTPPoints < PTS_MAJOR_GAME) // < 25 nBid = MAKEBID(nPartnersBid, 3); else nBid = MAKEBID(nPartnersBid, 4); // if (BID_LEVEL(nBid) == 3) status << "MCLR47! With " & hand.GetNumCardsInSuit(nAgreedSuit) & "-card support for partner's " & STS(nAgreedSuit) & ", and with only " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, we have to pass.\n"; else status << "MCLR47! With " & hand.GetNumCardsInSuit(nAgreedSuit) & "-card support for partner's " & STS(nAgreedSuit) & ", and with " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints & " pts in the partnership, we can go to game at " & BTS(nBid) & ".\n"; } // done! bidState.SetBid(nBid); bidState.SetConventionStatus(this, CONV_FINISHED); return TRUE; } else if (nStatus == CONV_RESPONDED_ROUND2) { // // round 3 -- we must've bid 4NT last time to ask for partner's minor // after partner's second Michaels cue bid // } // return FALSE; }