Skip to content

andrewimcclement/practice_bidding

Repository files navigation

practice_bidding alt-text Coverage Status

A short program to allow practice of new bidding systems in Bridge.


Requirements Python v3.6+ (f-strings are used ubiquitously).


Installation

git clone --recurse-submodules https://github.com/andrewimcclement/practice_bidding will ensure the required redeal submodule is installed at the same time.

Should you have any difficulties, please see https://git-scm.com/book/en/v2/Git-Tools-Submodules.


Usage:

From the command line, python C:\path\to\practice_bidding_main.py will use the XML_DEFAULT_SOURCE constant to locate the XML file describing the bidding system you wish to use, if you enter default when asked for the XML file location. Otherwise you may enter the file location at that point.

Alternatively, python C:\path\to\practice_bidding_main.py C:\path\to\system.xml will use the XML file located at C:\path\to\system.xml

You may wish to edit the XML_DEFAULT_SOURCE constant for your own usage. Please do not commit these changes.


Defining the XML bidding system:

See example_systems/chimaera.xml as an example.

<bid> element must always have a <value> element and a <desc> element. To be bid by the program, it must have at least one logical element as a child (to define when it should be bid). Subsequent bids should be included as child <bid> elements.

Logical elements

<and>, <or>, <not> elements allow the inclusion of arbitrary logical flows into the requirements for a bid. Only one such element should be a direct child of a <bid> element.

A <not> element can only have one conditional element inside. It will pass the hand if the condition inside does not pass the hand.

An <and> element can have multiple conditional elements inside. It will pass the hand if the hand does not fail any of the child conditional elements.

An <or> element can have multiple conditional elements inside. It will pass the hand if the hand passes at least one of the child elements.

Hence an empty <and> element will pass every hand while an empty <or> element will fail every hand.

[Deprecated] Alternatively <condition> elements may be used. A <condition> element must have a "type" tag as either "include" or "exclude" depending on whether the hand type should be included as a valid hand type or excluded as an invalid hand type for that bid. If there are multiple <condition> elements, a hand must pass the requirements for at least one include condition and not pass the requirements for any of the exclude conditions. (An empty condition will pass all hands.)

Non-logical elements

An <evaluation> element can be added inside a logical element. This can have various evaluation methods: <hcp>, <points> and <tricks>. With these elements, you can define <min> and <max> elements.

  • <hcp> evaluates a hand using the Milton Work Point Count if the attribute hcp="standard" is added to the root of the XML system file. An alternative point count hcp="chimaera" is defined with (A, K, Q, J, T) == (4.5, 3, 1.5, 0.75, 0.25) If neither are defined, it will fall back to the HCP function defined in a python file referenced by the XML system file (file location assumed to be in the same directory as the XML system file, referenced by addition of formulas="my_evaluation_methods.py")

  • <points> is the sum of <hcp> and the number of cards above 4 in each suit.

  • <tricks> will be the number of playing tricks.

Multiple <shape> elements can be defined inside a <condition> element. These must have a "type" tag, which must be one of "general", "shape", "clubs", "diamonds", "hearts", "spades", "longer_than" or "strictly_longer_than". A new "formula" type now supersedes "longer_than" and "strictly_longer_than" while allowing more elaborate constructions.

  • "general" allows you to use predefined general shape constraints such as "balanced", "unbalanced" etc.

  • "shape" allows you to define precise shapes eg 5431 for 5 spades, 4 hearts, 3 diamonds and 1 club, or (54)xx for 54 in the majors.

  • [DEPRECATED] A suit allows you define <min> and <max> lengths for that suit (inclusive). Note if min > max the program will throw when parsing the XML file.

  • [DEPRECATED] "longer_than" and "strictly_longer_than" <shape> elements require <longer_suit> and <shorter_suit> elements inside and allow you to define conditions such as len(hearts) > len(spades) for a hand.

  • "formula" <shape> elements allows the input of a equation in the lengths of the suits, e.g. hearts + spades > diamonds + clubs. +, *, - are all allowed (but not brackets). Exactly one operator of "==", "!=", "<=", ">=", "<", ">" must be used (replacing "<"/">" with "&[l/g]t;" where required).


Acknowledgements This would not be possible without the wonderful redeal library implemented in Python by Antony Lee. This project uses a forked copy, but the original can be found at https://github.com/anntzer/redeal.

About

A short program to allow practice of new bidding systems in Bridge.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages