|
|
|
|
|
|
Writing Rules for Bridge - Defining a Bridge Language
Back
|
|
|
|
|
|
|
Writing a set of bidding rules requires a simple language based around the
natural language of Bridge. This language must be easily readable and
understandable. But, it must also convey the precise meaning of every piece of
information influencing a bid. A set of rules written in this language should
proceed step by step through a reasoning process identical to a person bidding
this system. What should such a language look like? Let's start with the
vocabulary.
All of the individual pieces of information necessary for bidding may be thought
of as qualities. A hand has qualities such as point count and shape. Each of the
suits in the hand has qualities such as the name of the suit and the number of
cards in the suit. A person has qualities such as the seat order during a hand.
A bid has qualities such as the level of the bid and the suit of the bid.
There are many qualities that the language must define. Each quality must be
defined by specifying a word or phrase identifying the quality, what piece of
information the quality represents, what values the quality can assume, and how
the value of the quality gets set. Notice that the values that a quality can
assume may also be a single word or a phrase. So, the vocabulary includes all of
the words required to name all of the qualities and their allowable values. This
set of words and phrases may be divided into three categories.
First, there are words or phrases that convey a meaning in themselves. For
example, the word "shape" refers to a hand being balanced or
unbalanced. The phrase "point count" refers to a number representing
the strength of a hand as defined by a method of assigning points by card value
or suit length. Such phrases may be thought of as simple phrases, since their
meaning lies in the phrase itself and does not require determining the meaning
of the individual words making up the phrase.
The second category consists of phrases that derive their meaning from the
individual words. For example, "my partner's first bid" and "my
partner's second bid" are very similar. The difference in meaning being
determined by the difference in the ordinal number referring to the bid. The
meaning of these type of phrases is determined by an examination of each
individual word. Such complex phrases are necessary to describe qualities such
as the suit of a bid, where the exact value of the quality depends upon
specifying which bid of which player. The language must define a set of words
that can be used to build phrases referring to these type of qualities.
Last, the values that qualities can take are also words or phrases. For example,
the value of "shape" may be set to either "unbalanced" or
"balanced". These are the only two values that "shape" may
take. Other values may be numbers. "Point count" may be a number from
0 to 40.
For a definition of qualities of the first category, please refer to:
Qualities Represented by Words or Simple Phrases
For a definition of qualities of the second category, please refer to:
Qualities Represented by Complex Phrases
The values each of the qualities may assume are identified in the above
references.
In addition to the words and phrases required to name and give value to all of
the qualities, the language requires a few more words. These are words needed to
provide structure to the language, to guide the thought process as the qualities
and their values are considered. These additional words are more easily
explained in the context of the semantics of the language, covered in the
following section.
Once a vocabulary is established for the language, the syntax and semantics must
be defined. So, let us look at how words, simple phrases, complex phrases and
values can be strung together to form a thought process capable of selecting a
bid according to a bidding system.
First, what sort of ability is required of the language to simulate a thought
process capable of bidding? The language must allow:
 |
making decisions based upon the value of a quality.
|
 |
setting a quality to a specified value.
|
 |
inclusion of comments explaining a decision.
|
 |
bids to be made.
|
How does the language provide these four basic abilities? By specifying the
syntax of four types of rules.
- If rules
If left side comparison right side
The syntax of the "If" rule is the word If, followed by a
reference to some quality, followed by the type of comparison to perform,
followed by either a reference to another quality or a specific value to be
tested against. To execute the rule, the game determines the current value of
the quality and tests it, as specified, against the provided value. The result
of the test will be either true or false. The result of the test is then used to
determine which rule the game will execute next.
Which rule is executed after an "If" rule, is determined by the
indentation of the rules. That is, an "If" rule may have other rules
indented beneath it. These rules belong to the "If" rule. These rules
will only be executed when the parent "If" rule evaluates to true.
When the "If" rule evaluates to false, the child rules will be
skipped. Execution will proceed to the next rule that is at the same indentation
level or less than the "If" rule.
In the following example, when rule 1 is evaluated and found to be true, the
next rule executed would be rule 2. When rule 1 is evaluated and found to be
false, the next rule executed would be rule 3.
If rule 1
If rule 2
If rule 3
|
The "If" rule is the only rule that affects the game's order of
execution. All other rules are simply executed and the game proceeds to the next
rule.
Note that the right side of the "If" rule can be a reference to either
another quality or to a specific value. Obviously, if the right side is a
specific value, the value must be one of the values allowed for the quality on
the left side. If the right side is a reference to another quality, the
allowable values for the quality on the right side must be the same as the
allowable values for the quality on the left side. Both sides are evaluated to
determine their current value and their current values are tested according to
the comparison.
Some examples of "If" rules:
If shape is balanced
If point count <= 11
If length of my first bid suit >= 6
If If length of Hearts = 4
|
- Set rules
Set quality to value
The syntax of the "Set" rule is the word Set, followed by a
reference to some quality, followed by the word to, followed by the value
to set the quality. When the game executes a "Set" rule, the value of
the quality is set to the value specified.
Some examples of "Set" rules:
Set best suit to suit not selected
Set my partner's first bid to one in a suit
Set partner's point count min to 12
Set partner's point count max to 21
|
- Comment rules
Comment: text
The syntax of the "Comment" rule is the word Comment:, followed
by the text of the comment. When the game executes a "Comment:" rule,
the text is stored for review by the user.
Some examples of "Comment:" rules:
Comment: My partner opened the bidding with 1 in-a-suit
Comment: Partner has 12-21 points
Comment: With 19+ points jump bid a new suit
Comment: With 7 points or less and no 5+ card suit, pass
|
- Bid rules
Bid quality
The syntax of the "Bid" rule is the word Bid, followed by a
quality representing a bid. When the game executes a "Bid" rule, the
quality is evaluated to determine the bid to be made.
Some examples of "Bid" rules:
Bid 1 Spade
Bid 1 of best suit
Bid 2 of my first bid suit
Bid 2 of my partner's first bid suit
|
Now let's examine the semantics of the language, that is, how qualities and
values can be constructed in such a way that they convey a common meaning. As
explained above on this page, there are qualities that can be expressed using a
word or a simple phrase and there are qualities that require a complex phrase to
be expressed. There are also values of the qualities. Also, as seen from the
definition of the "If" rule, there are comparisons. Please continue
now to one of these pages for additional explanation of how qualities and values
are expressed in the language.
Qualities Represented by Words or Simple Phrases
Qualities Represented by Complex Phrases
Comparisons Used to Test Qualities
|