Skip to content

Seven-of-Di/ben

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bridge Engine

This is a game engine for bridge. It can be used as a robot player, to do analysis, or to develop AI for bridge.

The engine is built using machine learning (neural networks) and double dummy solvers through the python wrapper python-dds.

To get a first impression of how the engine plays, please take a look at the demo.

For a few examples of how you can use the engine for analysis or development, see the tutorials.

If you like the software, please consider making a donation to support the developers.

Donate

Getting Started

Installation

The engine runs on Python 3.7, with the neural networks using tensorflow 1.15

The recommended way of installing is in a conda environment.

For Windows users: After installing anaconda, you will have a new application called "Anaconda Prompt". Henceforth you will have to run all commands in "Anaconda Prompt" not in "cmd". The title bar of your command prompt window should read "Administrator: Anaconda Prompt (Miniconda3)"

Use the following command to install dependencies:

conda env create -f ./environment.yml

The bridge engine was developed on linux. It will likely work on any other platform which runs Python and conda, but was only tested on Windows 10 and Windows 11.

Running the Web App (native)

The engine has a (very basic) UI which enables you to play as a human agains three bots and then review the games you played.

The app runs in the browser, and the service has two components: (1) "webserver" which serves the UI through http, and (2) "gameserver" which serves the API to interface with the bots through websockets.

Following are instructions to start the service:

(If you are on Windows, make sure that you are in the "Anaconda Prompt", not in the default Windows command prompt)

make activate

Start the game server

(If you are on Windows you can omit sudo from the following commands)

make gameserver

And start the app server

make webserver

Running the Web App (Docker)

docker-compose up

Now you can use the browser to navigate to http://127.0.0.1:8080/home There will be a link "Play now". If you click that, a new board will be started and you can start playing bridge (you are South). After playing a hand, a link to an analysis page will appear on the home page. The UI was tested on Firefox, Chrome and Android.

image

Tutorials

The tutorials serve as illustration of the engine's API and functionality, and should be helpful as a starting point if you would like to use the engine in a more customized way for analysis or for development.

The examples run in jupyter notebooks, but it's also possible to just read them without installing anything.

  • Bidding shows how you can use the engine to bid hands and to sample hands which are consistent with a given auction
  • Opening Leads illustrates how the engine "decides" which card to lead
  • Card-by-card Analysis this example shows how the engine can go through an already played hand, analyse every bid made and every card played, and find possible mistakes. You can also give it a hand you played on BBO to see what the engine "thinks" about your play
  • Single Dummy Estimates this exemplifies the use of a neural network to predict how many tricks declarer will take in a given contract on a given opening lead. As opposed to double dummy solvers, the results are approximate, but much faster.

Play against itself and against other bots

To make the engine play against itself, execute this command:

sudo python game.py

After each board, it's possible to go through the play using the web UI.

To make the engine play against other bots:

First run the bridge monitor table manager server.

Then, run the command below to connect to the table manager using the blue chip bridge protocol

python table_manager_client.py <table-manager-IP> <port> ben West

that will connect to the table as West; the other seats can be taken similarly.

What the engine cannot do (yet)

Below is a list of features which aren't implemented in this engine yet, but you would probably expect them from a bridge robot:

  • can't play any other system except 2/1 (see convention card)
  • can't configure the bidding system and the conventions (it just plays what it plays and assumes the opponents play that as well)
  • can't alert
  • can't explain bids or understand explanations of bids
  • can't use or interpret defensive signals
  • can't claim or accept claims
  • it does reach good slams, but slam auctions are a bit weird
  • isn't deployed as a service which you could play with on the internet (you have to install it to use it)

Articles

How to cite

@misc{Dali2022,
  author = {Dali, Lorand},
  title = {Bridge Engine},
  year = {2022},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/lorserker/ben}},
}

About

a game engine for bridge

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 62.8%
  • Jupyter Notebook 27.0%
  • JavaScript 4.0%
  • HTML 3.6%
  • CSS 1.4%
  • Visual Basic .NET 0.8%
  • Other 0.4%