Backgammon Web API. Sophisticed neural net based multi-ply evalution engine for Backgammon moves

Backgammon Web API

Backgammon Web API. Sophisticed neural net based multi-ply evalution engine for Backgammon moves.

Based on GNU Backgammon (https://www.gnu.org/software/gnubg) under GPL license.

Features:

  • Calculate best moves for a given Backgammon position

Features to-do:

  • Calculate cube decisions

Want to see the Backgammon Web API in action? Have a look at https://github.com/foochu/bgweb-terminal.


Running the API server

Run via Docker

# 1 - install docker

# 2 - run the program:
docker run -p 8080:8080 -d foochu/bgweb-api:latest

# 3 - browse to http://localhost:8080

Run from source

# 1 - install Go

# 2 - clone this repo

# 3 - run the program:
go run .

# 4 - browse to http://localhost:8080

Get best moves

Parameters

  • board = Board layout
    • x = Layout for player x
      • 1 - 24 = Number of chequers at each point
      • bar = Number of chequers on bar
    • o = Layout for player o
      • 1 - 24 = Number of chequers at each point
      • bar = Number of chequers on bar
  • cubeful = Is doubling cube at play? Affects equity algorithm.
  • dice = 2-slot array of dice roll
  • max-moves = Max number of moves to return
  • player = Player who's turn it is to move, either x or o
  • score-moves = Calculate equity & winning chance. If false just returns list of legal moves.

Example

For example, get top moves for starting position and dice roll 3-1 for player x:

curl -L -X POST 'http://localhost:8080/api/v1/getmoves' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
--data-raw '{
  "board": {
    "o": {
      "6": 5,
      "8": 3,
      "13": 5,
      "24": 2
    },
    "x": {
      "6": 5,
      "8": 3,
      "13": 5,
      "24": 2
    }
  },
  "cubeful": false,
  "dice": [3, 1],
  "max-moves": 3,
  "player": "x",
  "score-moves": true
}'

Return moves in order of preference based on equity and winning chance:

[
  {
    "play": [
      {
        "from": "8",
        "to": "5"
      },
      {
        "from": "6",
        "to": "5"
      }
    ],
    "evaluation": {
      "info": {
        "cubeful": false,
        "plies": 1
      },
      "eq": 0.159,
      "diff": 0,
      "probability": {
        "win": 0.551,
        "winG": 0.174,
        "winBG": 0.013,
        "lose": 0.449,
        "loseG": 0.124,
        "loseBG": 0.005
      }
    }
  },
  {
    "play": [
      {
        "from": "13",
        "to": "10"
      },
      {
        "from": "24",
        "to": "23"
      }
    ],
    "evaluation": {
      "info": {
        "cubeful": false,
        "plies": 1
      },
      "eq": -0.009,
      "diff": -0.168,
      "probability": {
        "win": 0.497,
        "winG": 0.137,
        "winBG": 0.008,
        "lose": 0.503,
        "loseG": 0.14,
        "loseBG": 0.007
      }
    }
  },
  {
    "play": [
      {
        "from": "24",
        "to": "21"
      },
      {
        "from": "21",
        "to": "20"
      }
    ],
    "evaluation": {
      "info": {
        "cubeful": false,
        "plies": 1
      },
      "eq": -0.015,
      "diff": -0.175,
      "probability": {
        "win": 0.497,
        "winG": 0.125,
        "winBG": 0.005,
        "lose": 0.503,
        "loseG": 0.135,
        "loseBG": 0.004
      }
    }
  }
]
Similar Resources

Package figtree provides a multi-paradigm SDK for sophisticated configuration file access

Package figtree provides a multi-paradigm SDK for sophisticated configuration file access. Motivation Figtree syntax is based on classic key/value pai

Dec 31, 2021

Aws-console-plugin - The current HashiCorp Vault AWS Secret Engine currently supports the creation of short lived API keys using the IAM User

aws-console-plugin Background The current HashiCorp Vault AWS Secret Engine curr

Feb 7, 2022

An unofficial API based on Hasura API Reference.

An unofficial API based on Hasura API Reference.

Apr 14, 2022

Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Feb 6, 2022

Go library for the Spotify Web API

go-spotify Simple Go library for the Spotify Web API Installation go get github.com/rapito/go-spotify/spotify How-to-use Get Requests import "fmt

Nov 18, 2022

Whatsmeow is a Go library for the WhatsApp web multidevice API.

whatsmeow whatsmeow is a Go library for the WhatsApp web multidevice API. This was initially forked from go-whatsapp (MIT license), but large parts of

Dec 27, 2022

WhatsApp Web API

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Jan 7, 2023

Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Mar 19, 2022

Awspowertoggle - Web UI and API for quickly starting and stopping AWS environments

Awspowertoggle - Web UI and API for quickly starting and stopping AWS environments

aws-power-toggle web UI and API for quickly starting and stopping AWS environmen

Feb 23, 2022
Comments
  • Matches

    Matches

    Hey again, Does this code understand the concept of a match - i.e if you are in a match and the score is say 3-2 does it know this? Or is it taking each game as an individual game?

    I ask because the JSON format doesn't seem to know about match scores. Thanks again!

  • Ranking the player

    Ranking the player

    Hey again...

    I know that some backgammon engines can give a player ranking score based on the moves they play, and I presume GNU BG can aswell - is that exposed?

  • GNUbg ID/XGID board positions

    GNUbg ID/XGID board positions

    Can this port interpret XGID board positions - the GNU docs suggest GNU backgammon can but wondering if this port includes that?

    Would you consider adding it? Thanks

  • Calculate cube decisions

    Calculate cube decisions

    Hi, Really nice work porting this from C to Go. In the README it expresses:

    Features to-do:
    
    Calculate cube decisions
    

    I was wondering if this is underway - you have a plan to do this to complete this port to Go?

    Thanks

The Bhojpur PEE is a software-as-a-service product used as a Provider's Edge Equipment based on Bhojpur.NET Platform for application delivery.

Bhojpur PEE - Provider's Edge Equipment The Bhojpur PEE is a software-as-a-service product used as a Provider's Edge Equipment based on Bhojpur.NET Pl

Dec 31, 2021
Zms - The Bhojpur ZMS is a software-as-a-service product applied in different risk management areas. It is a containment Zone Management System based on Bhojpur.NET Platform.

Bhojpur ZMS - Zone Management System The Bhojpur ZMS is a software-as-a-service product used as a Zone Management System based on Bhojpur.NET Platform

Sep 26, 2022
Simple RESTful API for WhatsApp in Golang (using the Whatsmeow multi device library)
Simple RESTful API for WhatsApp in Golang (using the Whatsmeow multi device library)

WUZAPI WuzAPI is an implementation of @tulir/whatsmeow library as a simple RESTful API service with multiple device support and concurrent sessions. W

Dec 30, 2022
The Bhojpur.NET Platform automates the provisioning of ready-to-use Network, Security, and IT applications

Bhojpur.NET Platform The Bhojpur.NET Platform automates the provisioning of ready-to-use Network, Security, and IT applications Learn more ?? The Bhoj

Nov 9, 2022
The Bhojpur Ara is a software product used for automated resource assembly within Bhojpur.NET Platform ecosystem to enable delivery of applications and services.

Bhojpur Ara - Automated Resource Assembly The Bhojpur Ara is a service product used for automated resource assembly within the Bhojpur.NET Platform ec

Apr 28, 2022
A simple Kubernetes-native CI system for the Bhojpur.NET Platform.

Bhojpur Piro - Kubernetes-native CI A simple Kubernetes-native CI system applied by the Bhojpur.NET Platform. It knows no pipelines, just the jobs and

Apr 28, 2022
go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface

go-whatsapp-rest-API go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface Multi-devices (MD) Support. This ver

Dec 15, 2022
support multi autosolve instances for AYCD

AYCD AutoSolve Go Client Client for connecting to the AYCD AutoSolve network

Jun 26, 2022
A Pulumi multi language component to create an IAM role for an EKS cluster

xyz Pulumi Component Provider (Go) This repo is a boilerplate showing how to create a Pulumi component provider written in Go. You can search-replace

Oct 27, 2021
CoreDNS plugin implementing K8s multi-cluster services DNS spec.

multicluster Name multicluster - implementation of Multicluster DNS Description This plugin implements the Kubernetes DNS-Based Multicluster Service D

Dec 3, 2022