This directory contains codes for supervised learning of Bridge bidding.
The code is provided with a environment of Contract Bridge to create observation tensors in bridge_state.py
, which is a Python reimplementation based on OpenSpiel implementation of Contract Bridge.
We use Python 3.8 and Pytorch 2.0 to make datasets and train the network.
You can run the file make_dataset.py
to generate a dataset of Bridge bidding.
For default, we use the dataset played by WBridge5, which is released by the author of Human-Agent Cooperation in Bridge Bidding. You can download the dataset here.
You can also create your own dataset using the encoding of OpenSpiel, in short
- The cards are represented as
rank * kNumSuits + suit
. - The calls are represented in sequence: Pass, Dbl, RDbl, 1C, 1D, 1H, 1S, etc, starting from 52.
- Each trajectory in dataset is a sequence of actions, where first 52 actions are dealing, starting from north and going clockwise. Then the bidding and playing follows.
By running make_dataset.py
, you will get datasets in save_dir
, which are python dicts
of str, torch.Tensor.
After making datasets, you can run train.py
to train the network.
The arguments are explained below:
- dataset_dir: the directory to your dataset made.
- save_dir: the directory to save trained network.
- learning_rate: the learning rate of optimizer.
- train_batch_size: the batch size for train set.
- valid_batch_size: the batch size for valid set.
- num_episodes: the number of iterations.
- eval_freq: the frequency of evaluation (how many iterations).
- device: the device to train and evaluate on.