Overview of submodules
endplay is divided into six main components, each of which can interoperate with each other:
endplay.types
is the basis for the whole library, providing the classes which are used by all the other modules for encapsulating the key objects in bridge. The ‘master’ class isDeal
, whose state consists of the four hands in the deal, the cards played to the current trick, a trump suit and the player to lead to the current trick. All the methods one would expect to be defined on this are provided - accessing the hands, playing/unplaying cards from the current trick, importing and exporting from PBN format etc. From this class there is a hierarchy of typesDeal -> Hand -> SuitHolding -> Rank
which allows introspection of the deal at any level wanted. Many other types, such as containers for holding results from double dummy analysis and storing contracts, are also provided here.endplay.dealer
provides functions for generating bridge hands. The main function isgenerate_deals
which can accept a list of constraints (either functions which accept aDeal
object and returnTrue
/False
, or strings written in dealer syntax) and generates a specified number of deals which satisfy the constraints. Thedealer
module can also be run as a main module withpython3 -m endplay.dealer
(or simplyendplay-dealer
) which works very similarly to the Hans van Staveren dealer program, but with some different output options and extra functionality.endplay.evaluate
is the simplest component, consisting of a variety of functions which evaluate various properties of bridge hands, such as calculating high card points, shape, losers, controls and other algorithms for estimating the quality of a hand.endplay.dds
is a high-level wrapper around Bo Haglund’s dds library which takes care of converting between the different types and encodings it uses internally and providing sensible defaults for things such as the number of threads it uses. A lower level wrapperendplay._dds
, which is little more than the basicctypes
declarations, is also provided and is used internally by the dds functions when making library calls.endplay.parsers
provides tools for parsing common file types which are used as inputs and outputs for bridge software, this includes PBN and Dealer. These produce document tree representation of the input files and are used internally for many things, but can also be traversed manually to create programs which interact with other bridge software easilyendplay.interact
provides theInteractiveDeal
class which keeps an undo stack whenever its state is modified, making it easier to interact with the deal. The main purpose of the module is a CLI tool which provides a simple REPL for analysing bridge deals which is available as a main module withpython3 -m endplay.interact
(or simplyendplay-interact
)