BIDDING DATABASE CONSTRUCTION The bidding database as actually used by the program is in a file called mb.txt. This file is in fact produced from a source file mb.txt2 and a macro file mac.m4. The macro file iteratively replaces strings in mb.txt2 with their translations until no such strings can be replaced. Care must be taken to ensure that modifications to mb.txt2 do not inadvertently trigger a macro translation. Macros must begin with letters; in order to match a string, the character *before* the string must not be alphanumeric, @ or _, and the character after the string must not be alphanumeric or _. In order to construct mb.txt, put mb.txt2 and mac.m4 in the GIB directory and invoke bridge.exe with the -Q switch. WARNING: MODIFYING THE BIDDING DATABASE AND INVOKING GIB WITH THE -Q SWITCH IS NOT FOR THE FAINT OF HEART! AS AN EXAMPLE, INVOKING GIB WITH THE -Q SWITCH WILL OVERWRITE THE MB.TXT FILE THAT CONTAINS THE CURRENT BIDDING DATABASE. WHILE WE ARE HAPPY TO MAKE THE DATABASE AVAILABLE TO OUR USERS WHO ARE INTERESTED IN EXPERIMENTING WITH IT, THE DATABASE FORMAT IS NOT SUPPORTED. THE FORMAT IS COMPACT AND POWERFUL, BUT NOT INTENDED FOR USE BY CASUAL USERS. BIDDING SEQUENCE SPECIFICATION A bidding sequence consists of a sequence of bids, separated by colons. A bid is defined as [1-7][CDHSN]|P|X|R. PATTERN STRING SPECIFICATION The pattern string consists of the following 9 fields, in order: Pnn HCP Mnn points including distribution Dnsnsnsns length in four suits, longest to shortest Cnnnn length in four suits Lnn number of losers (Lindelof definition) HnnCnnDnnHnnS HCP in four suits, based on 8421 count Qnn controls SnCnDnHnS stoppers in four suits GnCnDnHnS suit quality in four suits (Lindelof definition) Definitions Stoppers in a suit 0 no other value 1 Qx or Jxx (partial stop) 2 Kx or Qxx (one likely stop) 3 A, QJx or 5+ HCP in the suit 4 length + HCP in suit at least 8 (two stops) Suit quality 0 no other value 1 3+ card length 2 4 cards 3 4 cards, 3/5 honors or 4+ HCP, or any 5+ cards (biddable) 4 would be type 3 if smallest card removed (rebiddable) 5 would be type 4 if smallest card removed (twice rebiddable) 6 type 5, also 8+ HCP or 4/5 honors 7 AKQTxx 8 AKQxxxx 9 AKJxxxxx or AKxxxxxxx Number of losers Total number of losers is obtained by adding the number of losers in each suit. The number of losers in a suit of length 3- is the length minus 1 for each of AKQ that is missing. Don't deduct for missing K with stiff, missing Q with stiff or doubleton. The number of losers in a suit of 4+ cards is 0 if the suit is solid, 1 if the suit is semisolid, and 2 otherwise. Solid means suit quality of 7+ or AKQJ. Semisolid means that making a small card the highest missing honor would make the suit solid. Points High card points and distributional points are both computed via a large lookup table, but correspond roughly to their usual values. RULE SPECIFICATION The same rule format is used by both the pattern matching and specification part of rules, so that a single parser can analyze both. Roughly speaking, the pattern matching is testing to see if a rule can fire; the specifications give the implied holdings if a bid is made. We give here the grammar for the rules. str [:_A-Z0-9]+ a string, suitable for matching astr [:_A-Z][:_A-Z0-9]* a string that might follow @ num [0-9] a digit lower [a-z] a lower case letter (a grab) iterator [*+?] an iteration indicator brackop [^<>] a bracket operator, [...] [^...] [<...] [>...] spectype [PMLQpmlq] a specification indicator, as in the pattern subspectype [DHSGdhsg] a specification indicator that accepts a suit argument suit [CDHS] a suit msuit [CDHSNPXR] a suit/suitlike character in math context The lexical analysis takes place in one of three contexts: BRACKETS means that you are parsing a bracketed character expression like [+#d]. MATH means that you are parsing a math expression, which is delimited by ~. SPEC means you are parsing a specification, which is delimited by `. ` START_SPEC_TOK; begins and ends SPEC context ~ MATH_TOK; begins and ends MATH context "["{brackop}? LBRACKET_TOK; begins BRACKET context, operator type included "[+"\+* LBRACKET_TOK; begins BRACKET context, number of + included. Matches the strain or number that is n above the strain or number in the brackets. "[-"\-* LBRACKET_TOK; begins BRACKET context, number of - included. Matches the strain or number that is n below the strain or number in the brackets. "]" RBRACKET_TOK; exits BRACKET context. *** SPEC context :{spectype} SPEC_TOK, including spectype information and a flag giving case (lower = upper bound, upper = lower bound). :{subspectype} SUBSPEC_TOK, including spectype information and a flag giving case (lower = upper bound, upper = lower bound). {suit} SUIT_TOK, including suit information. Gives the suit of specification information (e.g., quality is 5 in hearts). *** BRACKET context "-" DASH_TOK. Range of characters. *** MATH context {msuit} CHAR_TOK. Returns given character. "-" MINUS_TOK. Unary operator. ">=" BINARY1. Usual operator. "<=" BINARY1. Usual operator. ">" BINARY1. Usual operator. "<" BINARY1. Usual operator. "==" BINARY1. Usual operator. "!=" BINARY1. Usual operator. "&&" BINARY0. Usual operator. "||" BINARY0. Usual operator. "+" BINARY2. Usual operator. "*" BINARY3. Usual operator. "&" BINARY0. Usual operator. "|" BINARY0. Usual operator. "=" BINARY1. Usual operator; LHS must be grab and returns value of RHS. {lower} MGRAB. If < 0, retrieve value of given grab. a=-1, b=-2, etc. *** empty context "|" OR_TOK. Either of given matches must be true "&" AND_TOK. Both of given matches must be true *** any context @{astr} AT_TOK, including given string. Means that you restart the analysis after appending the given string to the bidding sequence @{num}{num}\+? GOTO_TOK, including 2-digit number and flag if + is present. Means that you jump to the given position in the string begin matched. If + is present, you can advance the position further as long as you don't bypass a :. This construct is generally not used in the database but is inserted by a preprocessor. . DOT_TOK. If matching, matches any single character. In math expression, reads the next field (a character or multi-digit number) from the string being matched. In a specification, means no constraint. \${num}* END_TOK. If the sequence begins "START" and contains n colons, it must match starting with a bid n+ colons before the end of the bidding sequence you're matching. So 6N:X$1 will match any sequence ending with 6N:X:ZZ for any call ZZ. is 0 if missing, so 6N:X$ matches any sequences ending in 6N:X. The restriction that the sequence begins START is to ensure that we only try matching these rules once. && GOTO_TOK. Same as above, but go to beginning of string. ! NOT_TOK. Must not match subsequent expression. ( LPAREN_TOK. Grouping. ) RPAREN_TOK. , COMMA_TOK. Matches any call (bid, pass, double, redouble). #{lower} GRAB. Retrieve *and match* given grab. {lower} PUSH. Grab the next field (character or digit) and store it as the given grab. The position in the string is not advanced. #{num}+ MGRAB. Call function #n in the dispatch table. {num}+ NUM. Return the given number. {iterator} ITERATOR. Inlucde information about type. {str} STRING_TOK, including string. CHAR_TOK is returned if the string is one character long Here is how these tokens are assembled into a string: goal : optexp at_tok A goal is an optional expression to match, followed by an optional AT_TOK : START_SPEC_TOK spec_list START_SPEC_TOK or a specification list optexp : altexp An optional expression is an expression : or nothing at_tok : AT_TOK An optional end token is an AT_TOK : or nothing altexp : regexp An expression is a regular expression, : altexp OR_TOK regexp or a disjunctive list : altexp OR_TOK GOTO_TOK regexp or such a list with a goto : altexp AND_TOK regexp or a conjunctive list : altexp GOTO_TOK regexp or an (implied conjunctive) list with a goto : GOTO_TOK regexp or a single expression with a goto regexp : rxpr A regular expression might or might : rxpr END_TOK have an END_TOK at the end of it rxpr : term An expresion is a term : rxpr term or a list of terms term : primary ITERATOR A term is a primary expression to match : primary perhaps without an iteration primary : DOT_TOK Match one character, always succeeds : MATH_TOK expr MATH_TOK The given expression is nonzero : COMMA_TOK Match any call : STRING_TOK Match the given string exactly : char Match the given character : NOT_TOK primary Given primary doesn't match : PUSH Match one field and save it, always succeeds : GRAB Match saved field : LPAREN_TOK altexp RPAREN_TOK Recursive invocation : LBRACKET_TOK classlist RBRACKET_TOK Match one element of the list char : CHAR_TOK The given character classlist : classitem A list of classes might be just one : classlist classitem item, or might be many classitem : CHAR_TOK DASH_TOK CHAR_TOK Range, like A-Z : char Specific character : GRAB Saved character expr : expr BINARY0 expr0 An expression is a binary expression (note right-to-left evaluation) : expr0 To next level of operator hierarchy expr0 : expr0 BINARY1 expr1 Binary operation : expr0 LBRACKET_TOK expr0 COMMA_TOK expr0 RBRACKET_TOK First expr is between next two : expr1 Next level expr1 : expr1 BINARY2 expr2 Binary operation : expr1 MINUS_TOK expr2 Difference of two expressions : expr2 Next level expr2 : expr2 BINARY3 expr3 Binary operation : expr3 Next level expr3 : LPAREN_TOK expr RPAREN_TOK Grouping. : NOT_TOK expr3 Logical negation : MINUS_TOK expr3 Mathematical negation : NUM The given number : CHAR_TOK The given character : MGRAB Either the saved field (grab a-z) or a functional invocation with no arguments (numeric) : MGRAB LPAREN_TOK list RPAREN_TOK Function of up to three arguments. The list elements are evaluated to get the args, which determine the arity of the function : DOT_TOK Pull the next field off the string list : expr COMMA_TOK list An argument list is comma-separated : expr or just one expression spec_list : spec_list1 specification, perhaps : MATH_TOK expr MATH_TOK a math expression, or a : MATH_TOK expr MATH_TOK spec_list1 specification including math expression spec_list1 : DOT_TOK Trivial specification : simple_spec single specification : simple_spec spec_list1 or a list thereof simple_spec : SPEC_TOK val A value for a field (e.g., controls) : SUBSPEC_TOK subspec_list Or a list of values for suits (e.g., suit quality) subspec_list : subspec Such a list can be one element : subspec subspec_list or many subspec : val suit A single specification gives a value and a suit val : NUM A value can be a number : GRAB or a saved/functional value (no arguments) : MATH_TOK expr MATH_TOK or a mathematical expression suit : GRAB A suit can be a saved value : SUIT_TOK or an explicit one A specification specifies what someone has shown. Fields where he hasn't shown anything can be dropped. . means nothing has been shown. Use upper case when a minimum has been shown and lower case when a maximum has been shown. A rule itself is a sequence of characters on a single line; rules may extend across multiple lines if the first character of the second and subsequent lines is a space or tab. If the first character is a semicolon, the rule is a comment. Otherwise, it is the following sequence: level def cr seq prio constraint spec *expl #id All of the fields are space delimited except for the first three, which are not. The level is an integer giving the depth of the auction. Def is either d or missing. If present, means that if this rule is a default rule, and is superseded by any higher or equal priority rule for the same bid. CR is one of the following: C This is a captaining bid; partner is not allowed to do anything other than make the book bid in response. R This bid relinquishes captaincy and partner can start thinking again. X If this is the suggested bid, make it without thinking. ? If this is the suggested bid, always simulate before making it. seq is a string that must match the bidding sequence as currently. prio is a number giving the priority. The general priorities are as follows: 80 shut up if you're both limited and partner bid your long suit (10440) redouble if you're doubled in a fit and have slam values (10341-10344) 78 a suited grand with enough values and no apparent losers (10015,10392, 10016) a suited small with enough values and a known loser (10016,10017,10393) a suited small with enough values and at most one loser, but no values for a grand (10018,10394) pass if you're doubled in a fit (10019-10022) Blackwood with no uncontrolled suit and values for small slam (10023, 10373,10400) quantitative 4NT (10025) or 5NT (10026) 76 cue bid if slam is possible (10027,10028,10415,10399,10029,10030,10405, 10407,10416,10408-10410) 74 7N with values and no fit (10033) 72 a small slam that might make with values (10419,10032) 6N with values and no fit (10034) 70 4M with values (10035) 3M in GF situation, known fit, with a possible slam (fast arrival) (10397) 5M over an opponent's bid, or P/X at 5 level, to invite slam (10036, 10336) jump to 5x to invite slam (10337) 3x to reveal a fit in GF situation with extra values (10396) 60 3M to reveal a fit with INV values (10037) 1/2M to reveal a fit without GF values (10462) 1-3M to reveal a fit with values for this level only (10463) 1-3M to show a 7-card fit if 8-card is impossible (10451) 50 new suit, quality 5, currently unshown (10038) 49 new suit, quality 5, currently shown quality 3 (10039) 48 new suit, quality 5, currently shown 3-card length (10422) 47 1-3m to reveal a fit without GF values (10459) 1-3M to show a 7-card fit if 8-card is impossible (10460) 46 new suit, quality 4 (10040) 45 new suit, quality 3 (10041) 44 rebid suit (10042) 40 3N to make (10043) 37 5m to make (10044) 33 4m bypassing 3N with a fit and possible slam (10045) 4m to reveal a fit in competition (10483) 4m over 3N with a void (10452) 30 2/3x with a fit and values for this level exactly (10046,10047) raise with a fit and values for this level exactly (10048) 25 1N to make (10441) 2N to INV (10374,10370) 6/7N to make (10414,10371) 20 double them (10051,10052) 19 pass if they bid your long suit (10437,10438) cue bid with game force (10418) 17 double them (10053,10054) 15 bid a Moysian fit at the 2/3 level and values for this level (10055) 10 overcall or balance with values for the level (10056) retreat to a known fit (10058,10375) run to another suit if it looks better (10352,10402,10354,10355,10403, 10353) 4M with nothing better to do (10366,10435) 9 bit NT if they haven't shown a fit (10059,10060,10364,10413,10420, 10421,10365,10423) constraint is a string that must match the bidder's pattern string. spec is a string that gives the bidder's minimum/maximum holding consistent with the bid. When you update what's known about a player's hand, you use the disjunction of all the specifications associated with the bid made. This isn't tested for matching, but is used to update information about what people have shown. The leading ` should not appear in the database and is instead added by the parser. expl is a number giving the id of the explanation. This field is optional. id is a number giving the ID of the rule.