Giter Club home page Giter Club logo

ben's Introduction

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)"

After installing conda, execute the commands in the conda_setup.sh script to create an environment and install the dependencies.

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

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) "appserver" 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:

First, make sure that you are located in the src directory

cd src

Activate the conda environment

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

conda activate ben

Start the game server

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

python gameserver.py

And start the app server

python appserver.py

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}},
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.