The Input File

Basic Layout

The basic lay-out of the file is:
 command1 "parameters for command 1"
 command2 "parameters for command 2"
 ...
 condition "list of conditions"
 action "list of actions"
The exact format is free, as long as it is unambigous, the program will understand it; in other words, lines can be broken freely, wherever it is desired to do so. Any line starting with a #-sign is regarded as a comment and ignored.

Comments can also be placed at the end of any line, from a marker of "//" all the way to the end of the line; or, independent of line structure, by starting the comment with a marker of "/*" and ending it with a marker of "*/".

Lexical structure

All the words recognized by the program act as keywords, that is, reserved words -- you cannot use those words as identifiers for other purposes, or you will get a syntax error.

For many such keywords, both the singular and plural forms are recognized and accepted interchangeably; this also means both forms are reserved. This plural/singular duality applies to the following keywords: club, diamond, heart, spade, notrump, hcp, jack, queen, king, ace, loser, control, trick and imp.

Inputs

The program knows several basic commands, each consisting of a keyword and a parameter. A parameter can be a single value or an expression that will be evaluated for every generated deal. Besides that, the program allows the user to create identifiers and assign expressions to them. The identifiers can be used as parameters for the basic commands or inside other expressions, and this is exactly equivalent to using the expressions they denote.

Expressions

An expression looks like regular C-code, with all normal operators that make sense in a bridge program present: Besides that, special operators useful in a bridge-program are provided:

Actions

Note that multiple "print" actions, while not forbidden, are not guaranteed to work sensibly. printoneline and printes are roughly "designed" to work with each other, but most other combinations will not produced the overall hoped-for output format; experiment. Actions whose names do not start with "print", i.e. average and frequency, do generally co-operate sensibly with each other and with one print action (or a series of printoneline/printes ones), but, again, experiment is advised.

The different actions are:

The program allows for and unlimited number of actions. More than one print action is allowed, but, depending on the actions involved, this may or may not give the desired results.

An example

Back to the "you hold ..." problem. Suppose we want to generate 25 hands that match these specifications on a slow machine, so we don't want to generate too many hands. This is accomplished with the following input file:
generate   10000
produce    25
vulnerable EW
dealer     west
predeal    south SAQ542, HKJ87, D32, CAK
west1c   = hcp(west)>11 && clubs(west)>= 3
# Condition describing west's 1C opener.
north2d  = diamonds(north)>=6 && (hcp(north)>5 && hcp(north)<12)
# Condition describing north's 2D overcall.
condition  west1c && north2d
# Require that west bids 1C and north 2D
action     printall
This produces 25 hands, including, for example, with this one:
J 7 3               9 8                 A Q 5 4 2           K T 6
3                   9 6 4 2             K J 8 7             A Q T 5
K Q J T 9 8 5       7                   3 2                 A 6 4
T 5                 9 8 7 4 3 2         A K                 Q J 6
Note that the hands that you get depend on the seed of the random generator, so, unless you use the -s flag to set the random generator seed, the hands that you produce will be different.

You can now start to analyze the hand and decide on the best action for east. However, if you look carefully at the west-hand, then you see that west could have opened this with a 15-17 NT. If you look at other hands, west might have opened 1D, 1H or 1S. These hands are excluded by:

west1d = diamonds(west)>clubs(west) || ((diamonds(west)==clubs(west))==4)
west1h = hearts(west)>= 5
west1s = spades(west)>= 5
west1n = shape(west, any 4333 + any 4432 + any 5332 - 5xxx - x5xx) &&
         (hcp(west)>14 && hcp(west)<18)
west1c = hcp(west)>11 && clubs(west)>= 3 &&
         (not west1n) && (not west1s) && (not west1h) && (not west1d)
A next run shows that north will occasionally overcall 2D on 8-card suit or with a side 4 or 5 card major. These distributions are excluded with:
north2d = (hcp(north)>5 && (hcp(north)<12) &&
          shape (north, xx6x + xx7x - any 4xxx - any 5xxx)
making the complete example:
generate   10000
produce    25
vulnerable ew
dealer     west
predeal    south SAQ542, HKJ87, D32, CAK
west1n = shape(west, any 4333 + any 4432 + any 5332 - 5xxx - x5xx) &&
         hcp(west)>14 && hcp(west)<18
west1h = hearts(west)>= 5
west1s = spades(west)>= 5
west1d = diamonds(west)>clubs(west) || ((diamonds(west)==clubs(west))==4)
west1c = (not west1n) && hcp(west)>10 && clubs(west)>=3
         && (not west1h) && (not west1s) && (not west1d)
north2d = (hcp(north)>5 && hcp(north)<12) &&
          shape(north, xx6x + xx7x - any 4xxx - any 5xxx)
condition  west1c && north2d
action     printall

A number of examples can be found in Examples.zip.