bdeal
bdeal documentation is here.
API for programmers
Documentation is here.
GUI version
Deals downloading scripts
Introduction
Bridge Calculator can automaticaly download tournament's deals from the Internet. To do this, it use the scripts dedicated for particular tournaments. Each script download adresses (URLs) from which the program will be able to download the distributions of hands. Each script is a file with a .lua extension.
Script's paths
- The program is looking for scripts (files ending with .lua) in the following locations (the last two are searched only by program's versions for GNU/Linux):
<working directory>/downloaders/
<user's home directory>/bcalc/downloaders/
<user's home directory>/.bcalc/downloaders/
/var/lib/bcalc/downloaders/
How to write a script?
Bridge Calculator supports scripts written in a Lua language.
Lua is one of the most popular scripting language. There are many tutorials for Lua in the Internet. Also many books about this language exists. One of this book is very good, available on-line, Programming in Lua by Roberto Ierusalimschy. I also recommend studing already existing scripts which are distributed along with Bridge Calculator.
Script file should be saved using the UTF-8 or ASCII encoding, and the first its line should contain a comment with the name of the tournament (recommended format is: <name of place where tournament is play>, <name of tournament>).
In scripts written for Bridge Calculator You can use all Lua's standard libraries.
- Also, some addtional functions are available:
- url.download(address) - download from given address (URL) and return (as string) the content of file, return nil in error cases;
- url.download_check(address) - download from given address (URL) and return (as string) the content of file, or, in error cases, show error message and break script execution;
- url.escape(str);
- url.unescape(str).
- Script should fill the results array. Each cell in results array describes one tournament's file with deals and is a table which can have the following fields:
- url - address of file which includes hands distribiutions
- name - (optional) the name displayed to the user
Console version
Non-interactive work (using in scripts, etc.)
Program can work without interact with user which can be usable when it is used for (typically massive) calculations in scripts (shell scripts, etc.). For example you can execute:
bcalconsole -e e -t <trumph> -l <leader> -q -d <format> -c <deal>
- Where following arguments means:
- -e e - program exits just after start, -e cause executing commands (for example cards play) just after program starts, in example only one command e cause program exiting, but generally, you can put more commands separated by spaces (but remember to place all in quotes), for example to make calculation after play As of heart on lead and exit: -e "AH e";
- -t <trumph> - set trump suit, for example -t s is for spades, and -t a cause calculation and print results for all trumps;
- -l <leader> - set leader hand, for example -l N;
- -q - (optional) make output less verbose (quiet mode) and easier to parse;
- -d <format> - set format of deal, for example -b PBN;
- -c <deal> - set deals hands using format given with -d switch, for example -c "S:T74.73.KQ87.7654 QJ53.AKT542..KQ3 8.Q96.AJT32.AJ92" (you can skip last hand only if it can be deduced, that is each player has 13 cards).
Please execute program with --help switch to see more details and options:
bcalconsole --help