endplay.dealer
- endplay.dealer.actions
- endplay.dealer.actions.templates
- endplay.dealer.actions.base
BaseActions
BaseActions._abc_impl
BaseActions.average()
BaseActions.frequency1d()
BaseActions.frequency2d()
BaseActions.print()
BaseActions.printall()
BaseActions.printcompact()
BaseActions.printes()
BaseActions.printew()
BaseActions.printoneline()
BaseActions.printpbn()
BaseActions.write()
BaseActions.write_postamble()
BaseActions.write_preamble()
- endplay.dealer.actions.html
- endplay.dealer.actions.latex
- endplay.dealer.actions.terminal
BaseActions
BaseActions._abc_impl
BaseActions.average()
BaseActions.frequency1d()
BaseActions.frequency2d()
BaseActions.print()
BaseActions.printall()
BaseActions.printcompact()
BaseActions.printes()
BaseActions.printew()
BaseActions.printoneline()
BaseActions.printpbn()
BaseActions.write()
BaseActions.write_postamble()
BaseActions.write_preamble()
HTMLActions
LaTeXActions
TerminalActions
- endplay.dealer.__main__
- endplay.dealer.constraint
ConstraintInterpreter
ConstraintInterpreter._dispatch_function()
ConstraintInterpreter._dispatch_operator()
ConstraintInterpreter._evaluate_shape()
ConstraintInterpreter._fn_cccc()
ConstraintInterpreter._fn_control()
ConstraintInterpreter._fn_hascard()
ConstraintInterpreter._fn_hcp()
ConstraintInterpreter._fn_if()
ConstraintInterpreter._fn_imps()
ConstraintInterpreter._fn_loser()
ConstraintInterpreter._fn_quality()
ConstraintInterpreter._fn_score()
ConstraintInterpreter._fn_shape()
ConstraintInterpreter._fn_suit()
ConstraintInterpreter._fn_trick()
ConstraintInterpreter._op_add()
ConstraintInterpreter._op_and()
ConstraintInterpreter._op_div()
ConstraintInterpreter._op_equal()
ConstraintInterpreter._op_geq()
ConstraintInterpreter._op_greater()
ConstraintInterpreter._op_leq()
ConstraintInterpreter._op_less()
ConstraintInterpreter._op_mod()
ConstraintInterpreter._op_mul()
ConstraintInterpreter._op_not()
ConstraintInterpreter._op_notequal()
ConstraintInterpreter._op_or()
ConstraintInterpreter._op_sub()
ConstraintInterpreter._re_namedpt
ConstraintInterpreter._re_pt
ConstraintInterpreter._re_suit
ConstraintInterpreter.evaluate()
ConstraintInterpreter.get_env()
ConstraintInterpreter.lambdify()
ConstraintInterpreter.parse()
ConstraintInterpreter.reset_env()
ConstraintInterpreter.set_env()
ConstraintInterpreter.unset_env()
- endplay.dealer.generate
- endplay.dealer.runscript
Functionality for generating bridge deals. This submodule provides an API via
generate_deals()
as well as an executable module which can be run with
python3 -m endplay.dealer and which aims to emulate the behaviour of
Hans van Staveren’s original dealer program
Functions:
|
Generates a random deal satisfying the constraints, giving 13 cards to each player. |
|
Generates produce random deals satisfying the constraints which should be given as for |
|
Execute a dealer script file |
- endplay.dealer.generate_deal(*constraints: Union[Callable[[Deal], Union[float, int, bool]], str], predeal: Deal = Deal('N:... ... ... ...'), swapping: int = 0, seed: Optional[int] = None, max_attempts: int = 1000000, env: dict = {}) Deal
Generates a random deal satisfying the constraints, giving 13 cards to each player. The constraints should be supplied as functions taking a whole deal and returning a boolean, for example lambda d: hcp(d.north) > 10, or as expressions compatible with the dealer expression syntax (see https://www.bridgebase.com/tools/dealer/Manual/input.html#expr)
- Parameters:
constraints – Constraints, as callables or strings
predeal – A
Deal
object which may be partially filled with cards; these will not be shuffled, allowing you to specify that players should have particular holdings.swapping – An integer representing the type of swapping algorithm to use, either 0 (no swapping), 2 (swapping EW) or 3 (swapping EWS)
seed – The number to seed the random generator with. A numpy random generator is used which is guaranteed to be stable between Python releases.
max_attempts – Maximum number of shuffles to perform when finding a deal which matches the constraints. Set to -1 for infinite
env – A dictionary of the environment used when evaluating constraints
- endplay.dealer.generate_deals(*constraints: Union[Callable[[Deal], Union[float, int, bool]], str], predeal: Deal = Deal('N:... ... ... ...'), swapping: int = 0, show_progress: bool = False, produce: int = 40, seed: Optional[int] = None, max_attempts: int = 1000000, env: dict = {}, strict: bool = False) Iterator[Deal]
Generates produce random deals satisfying the constraints which should be given as for
generate_deal()
. produce and max_attemps are upper limits, the first to be reached terminates the program- Parameters:
constraints – Constraints, as callables or strings
predeal – A
Deal
object which may be partially filled with cards; these will not be shuffled, allowing you to specify that players should have particular holdings.swapping – An integer representing the type of swapping algorithm to use, either 0 (no swapping), 2 (swapping EW) or 3 (swapping EWS)
show_progress – If True, a progress bar is displayed with information on how many hands have been generated so far
produce – The total number of hands satisfying the constraints to find.
seed – The number to seed the random generator with. A numpy random generator is used which is guaranteed to be stable between Python releases.
max_attempts – Maximum number of shuffles to perform when finding a deal which matches the constraints. Set to -1 for infinite
env – A dictionary of the environment used when evaluating constraints
strict – If True, a RuntimeError is raised if max_attempts is reached before produce hands are produced. Otherwise, a warning is generated
- endplay.dealer.run_script(script: Optional[str], show_progress: bool = False, produce: int = 40, generate: int = 1000000, seed: Optional[int] = None, verbose: bool = False, swapping: int = 0, outformat: str = 'plain', outfile: Optional[str] = None, constraints: list[str] = [], actions: list[str] = [], predeal: str = '', board_numbers: bool = False) list[endplay.types.deal.Deal]
Execute a dealer script file
- Parameters:
script – The name of the script file to run
show_progress – Display a progress meter while hands are generated
produce – The number of hands to produce
generate – The maximum number of shuffles to perform
seed – The seed for the random number generator
verbose – Print extra debugging info and statistics at completion
swapping – The swapping algorithm to use (0=no swapping, 2=swap EW, 3=all permutations of SEW)
outformat – The format to print output in: ‘plain’, ‘latex’ or ‘pdf’
outfile – A filename to write the output to, if None then printed to stdout
constraints – A list of extra constraints to apply
actions – A list of extra actions to apply
predeal – A list of players and the suit holdings to deal to them
board_numbers – If True, print board numbers along with the generated deals
- Returns:
The generated deals in a list