Skip to main content

Python3 bindings for GNUBG neural evaluation

Project description

GNUBG Neural Networks

PyPI Downloads Build & test wheels C/C++ Lint Branch naming Release to PyPI GitHub issues License Stack Overflow

GNUBG Neural Networks (this package, gnubg-nn) is a library that provides Python bindings to the GNUBG neural-network evaluation engine — the same engine used for position analysis and cube decisions in the full GNU Backgammon application, but packaged as a standalone library for use in scripts, analysis tools, and applications. It is not the full backgammon game (GUI, match play, etc.).

Quick Start

gnubg_nn is a native Python extension module that wraps the GNUBG neural-net evaluation library, so you can call the same position-analysis and cube-decision routines that power the full GNU Backgammon application from any Python 3.10+ script or application. It’s ideal for batch processing, data-science workflows, or building custom tools and UIs.

Installation

pip install gnubg-nn

Getting Started

import gnubg_nn

# Load the engine (weights, bear-off tables, etc. are initialized)
gnubg_nn.initnet()

# Convert a position key (20-char A–Z or 14-char Base64) to a board
board = gnubg_nn.boardfromkey("4HPwATDgc/ABMA")

# Evaluate win/gammon/backgammon probabilities and equity at 4 plies
win, gamm, bg, equity = gnubg_nn.probabilities(board, 4)

print(f"Win: {win:.3f}, Gammon: {gamm:.3f}, Backgammon: {bg:.3f}, Equity: {equity:.3f}")

That’s all you need to get up and running! For detailed API docs, advanced build options, and configuration, see the sections below or visit the full documentation on ReadTheDocs.

It provides:

  • Engine initialization & data loading (neural-net weights, opening-book, bear-off tables)
  • Position classification (classify) & public-evaluation best move (pub_best_move)
  • Board ↔ ID conversions (board_from_position_id, board_from_position_key, key_of_board, position_id)
  • Dice utilities (roll) & cube utilities (best_move, pub_eval_score)
  • Bear-off tools (bearoff_id_2_pos, bearoff_probabilities)
  • Legal-move enumeration (moves) & probabilistic evaluation (probabilities)
  • Monte-Carlo rollouts (rollout, cubeful_rollout)
  • Equity lookup (equities.value(xAway, oAway))
  • Runtime engine tuning via the set submodule

🧪 Platform Compatibility

Python Version Linux x86_64
(glibc ≥ 2.17)
Linux i686
(glibc ≥ 2.12)
macOS universal2 Windows x86_64
3.14 ✅ (macOS ≥ 10.14)
3.13 ✅ (macOS ≥ 10.14)
3.12 ✅ (macOS ≥ 10.14)
3.11 ✅ (macOS ≥ 10.9)
3.10 ✅ (macOS ≥ 10.9)

Notes:

  • ✅ = Built and available
  • ❌ = Not built
  • macOS universal2 = Supports both ARM64 and x86-64 architectures

Testing

gnubg-nn-pypi has some basic unit testing. After installation, run:

python3 -m unittest discover -s gnubg_nn.tests

AI-Assisted Development

Parts of this project were developed with the assistance of generative AI tools.

Specifically, the following models were used:

  • GPT-4o (OpenAI ChatGPT)
  • o4-mini-high (OpenAI ChatGPT)

These models were used to assist with code generation, documentation drafting, and architectural guidance. All outputs were reviewed and curated by a human before inclusion.

⚠️ Disclaimer:
Although human-reviewed, some AI-generated content may contain mistakes, inaccuracies, or outdated practices. Contributors and users should critically assess all code, comments, and documentation. We welcome corrections and improvements via pull requests or issues.

Code of Conduct

Please read the Code of Conduct to learn how to interact positively.

Contributing

Your expertise and enthusiasm are welcome! You can contribute by:

  • Reviewing and testing pull requests
  • Reporting and triaging issues
  • Improving documentation, tutorials, and examples
  • Enhancing engine parameters or submodules
  • Maintaining website or branding assets
  • Translating materials
  • Assisting with outreach and onboarding
  • Writing grant proposals or helping with fundraising

For more information, see our Contributing Guide. If you’re unsure where to start, open an issue or join the discussion on our mailing list!

Acknowledgments

This project builds upon the extensive work of the GNU Backgammon (GNUBG) community. The gnubg-nn library is the neural network evaluation component; the full backgammon application (GUI, match play, etc.) is maintained separately. We specifically acknowledge the pygnubg program developed by Joseph Heled.

We express our gratitude to all contributors who have dedicated their time and expertise to the development of the GNUBG neural network library and its Python bindings.

  • AUTHORS.md: A list of primary contributors to the gnubg-nn-pypi project can be found here.
  • GNU Backgammon (full project) credits.sh: For a comprehensive list of contributors to the full GNUBG application, please refer to the credits.sh file.

We also thank the broader GNUBG community, including testers, translators, and mailing list participants, for their invaluable support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gnubg_nn-1.1.0a6-cp313-cp313-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.13Windows x86-64

gnubg_nn-1.1.0a6-cp313-cp313-musllinux_1_2_x86_64.whl (9.5 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

gnubg_nn-1.1.0a6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

gnubg_nn-1.1.0a6-cp313-cp313-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gnubg_nn-1.1.0a6-cp312-cp312-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.12Windows x86-64

gnubg_nn-1.1.0a6-cp312-cp312-musllinux_1_2_x86_64.whl (9.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

gnubg_nn-1.1.0a6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

gnubg_nn-1.1.0a6-cp312-cp312-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gnubg_nn-1.1.0a6-cp311-cp311-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.11Windows x86-64

gnubg_nn-1.1.0a6-cp311-cp311-musllinux_1_2_x86_64.whl (9.5 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

gnubg_nn-1.1.0a6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

gnubg_nn-1.1.0a6-cp311-cp311-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gnubg_nn-1.1.0a6-cp310-cp310-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.10Windows x86-64

gnubg_nn-1.1.0a6-cp310-cp310-musllinux_1_2_x86_64.whl (9.5 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

gnubg_nn-1.1.0a6-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

gnubg_nn-1.1.0a6-cp310-cp310-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file gnubg_nn-1.1.0a6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: gnubg_nn-1.1.0a6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 9.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for gnubg_nn-1.1.0a6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 716b8567bb98cb505fbed67a0a1e8209f25f757c9ca93c1b741787924412c6b2
MD5 a3349f26e7d88fba5ba00d377ac21598
BLAKE2b-256 e1c6e68252b54bf8ec5e1184941576c0e2239424af6d4f8001593837cb4a9713

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c3373572a2427e8b4963b096a0587fb2fcc9b5d169710c3e9522fa9bc7de7644
MD5 ac3430d32c7bd08dc51b4eb1a68fd94b
BLAKE2b-256 75b9a3b6a79eefad25436d8a45b9564b606caf13598af291f38f93f0a4eceb29

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5e8b7ddf61ac56d225542ecff2c261c930b6f427d70ce051afd59ef20302ef66
MD5 db8db0b34aeaa367da781ec655171190
BLAKE2b-256 2a7f065c797123cfb70e1e9bf52ece8ec6e2ea502224ac5121b90fa847b3a087

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf6eeb1feb6e8cea67f0044a74d3354dd98ed1d730721a9dbcf1933670d4ff99
MD5 7da8b2848c87cce8a3515c507b245c7d
BLAKE2b-256 e7e10185f0e8357eaba48f421495934419b09a6a71fa28702e05ab4884cb543a

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: gnubg_nn-1.1.0a6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 9.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for gnubg_nn-1.1.0a6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 18e835af33c8260fb8420ab0a5840591f075661e0a3c3463f37c3fa0a51b1ad7
MD5 7068f1cb884bfd7222e4e8b7d19cb764
BLAKE2b-256 098e734cf2bdba085731818f594325918c8af36e4e46c77824ed39b273c7e039

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 aefdc30e37edf6c3eb7e7977fff76e2dece45b85ef875d141acbd87399d14b8a
MD5 7fcccd75e7d9074ce6215a99b2046d56
BLAKE2b-256 cba7ec83248ecdfa61ffa11bd2dc111baee07d00c5a2d284716dc2162946b7ed

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b501ef59eb386343ce7bc2951d4e8d01b4030e00da019313a8b8410bd7a09a53
MD5 c39c7063310881b62c5698314d1326b3
BLAKE2b-256 2f9f6072601122605933ea412b356d71198d2dfc06fc175c95b9ef6795e34b5e

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abaf865243d3144adc55fd80f0b307ab643d4de6f4a7f7251c9ac6d7b82e7b34
MD5 31ef64fa0a185c1805aa5536da23a6a0
BLAKE2b-256 f8f1a24da86f60744dda1df11baad5701c15a75eddb935983033937dc5284551

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: gnubg_nn-1.1.0a6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 9.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for gnubg_nn-1.1.0a6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 70b910fe8a141654cc6a633351c3f863c20899ef9e744d796a1c60ff6bd26d54
MD5 925a7c8cd54ac994fc5915af4e41a384
BLAKE2b-256 5ddf30584c452ad845b181e61c6ff80f08a4d97ba781d79943593fb98439cb22

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f16d0c31bb7226f744fc42873550a82ca3535a2f513a4b2b2cad034fd5dcce5c
MD5 4ec1a715a2c49d2c8cf8f31cd38e32f0
BLAKE2b-256 e5ae7320177263dfde16ebace52c5adb23218a26f8a7d1d814585f2a79ea914d

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 753a5a3a7336ae5839b55f6bf24f7e1276beda903e486559dcd8fbfd17d6f483
MD5 e15ff2e638392242b57da0184823ca4c
BLAKE2b-256 da8df1d478dc2e2dea10daf4f1dfc3530f5ec3d457025a9c7cfb3f49340d7638

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f5df7b6a4e89ff059d65397c91c8fa1299e6ef97484e42112ad66a7321113db
MD5 d4e6abe9f7b648b98502a1b89909ccba
BLAKE2b-256 9a9515e0dabd4ebff1a305075266f5d6985bcc9330469496d11a30e42a0b3498

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: gnubg_nn-1.1.0a6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 9.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for gnubg_nn-1.1.0a6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 79989bf9d9355f3917df1ecc404c7c743c25c7e5dc3a22926cfa63e85f57e377
MD5 ffa2eb9e4912975abf1cbc95646b255c
BLAKE2b-256 be28723156b6763b620c8ee470e5f606acd4b14d3d5f350213d460ee5ec37f6a

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cff2cc854aa8581e12ffb0d63036f73fba4c6f4db5bfdd29640a27e625d59fb9
MD5 673793efd2f6de26b7ae704d09539af1
BLAKE2b-256 27e83de7d6a666ebddcb54a2d783bd77e5da41e84f901884bdccd9da7a27005b

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2bfc7e0d98f2f22665008596cac7f3eabb83e459f43b4633553832c5c16268e8
MD5 b0d4e8d60f1417ece27a9c205ef7bd38
BLAKE2b-256 62bafb2da320f83e3717ed7b0aa9236cd3ee10245a6ca91d47b1e44cdf86e815

See more details on using hashes here.

File details

Details for the file gnubg_nn-1.1.0a6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gnubg_nn-1.1.0a6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7f613cbe282e0da5c063608290efd291dd200b859047f324ca8c5ff6375e0da
MD5 0baf51b06f2eb9e4275ff94b425a9ef9
BLAKE2b-256 65e29efe0ead2bf1fe420b9a9ae58ddc5ba3e2c5c674e6ec43e836f76f79b296

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page