Metadata-Version: 2.4
Name: bitbully-databases
Version: 0.0.2
Summary: Opening Databases for the Board Game Connect-4
Author: Markus Thill
Maintainer: Markus Thill
License-Expression: MIT
Project-URL: Homepage, https://github.com/MarkusThill/bitbully-databases
Project-URL: Issues, https://github.com/MarkusThill/bitbully-databases/issues
Keywords: connect-4,opening book,database
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: commitizen; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: readme_renderer[md]; extra == "dev"
Requires-Dist: keyrings.alt; extra == "dev"
Requires-Dist: pydoclint; extra == "dev"
Requires-Dist: mkdocs; extra == "dev"
Requires-Dist: mkdocstrings[python]; extra == "dev"
Requires-Dist: mkdocs-material; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pyrefly; extra == "dev"
Provides-Extra: notebooks
Requires-Dist: matplotlib; extra == "notebooks"
Requires-Dist: ipywidgets; extra == "notebooks"
Requires-Dist: ipympl; extra == "notebooks"
Requires-Dist: numpy; extra == "notebooks"
Provides-Extra: ci
Requires-Dist: pytest; extra == "ci"
Requires-Dist: ruff; extra == "ci"
Dynamic: license-file

# bitbully-databases
Opening Databases for the Board Game Connect-4.

<h1 align="center">
<img src="https://raw.githubusercontent.com/MarkusThill/bitbully-databases/master/bitbully-databases-logo.png" alt="bitbully-logo-full" width="400" >
</h1><br>

**BitBully Databases** is a companion library to [BitBully](https://github.com/MarkusThill/BitBully) that provides precomputed **Connect-4 opening books** with millions of evaluated positions.
It includes a **pure-Python reference implementation** (no NumPy dependency) demonstrating how to read, search, and interpret these binary databases — ideal for educational use and exploration.
For high-performance inference, use the native **C++/pybind11 BitBully API** to access and query the databases.


## Install

Install `bitbully-databases` via pip:

```bash
pip install bitbully-databases
```

## Usage

```python
import bitbully_databases as bbd

# Load the 12-ply book with distances (default)
db = bbd.BitBullyDatabases("12-ply-dist")

# Get the absolute file path of the packaged database
path = bbd.BitBullyDatabases.get_database_path("12-ply-dist")
print("Database path:", path)

# Check database metadata
print("Book size:", db.get_book_size())
print("Memory size (bytes):", db.get_book_memory_size())
print("Contains win distances:", db.has_win_distances())

# Example Connect-4 board (bottom → top)
# Player 1 (yellow, X) will eventually win
board = [
    [0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0],
    [0, 1, 0, 2, 0, 0, 0],
    [0, 2, 0, 1, 0, 2, 0],
    [0, 1, 0, 2, 0, 1, 0],
    [0, 2, 0, 1, 0, 2, 0],
]

# Retrieve the evaluation score for the board
value = db.get_book_value(board)
print("Book value:", value)
if value is not None and db.has_win_distances():
    print(f"→ Player 1 wins in {100 - abs(value)} moves.")

# Display whether the database uses distances and the type of book
print("Has win distances:", db.has_win_distances())
```

## Further Usage Examples and API Reference

You will find further examples and the full API reference under [https://markusthill.github.io/bitbully-databases/](https://markusthill.github.io/bitbully-databases/)

# Development (Debian-based Systems)

## Install & Activate virtualenv

```bash
python3 -m venv venv
source venv/bin/activate
```

## Install Dependencies

```bash
pip install -e .[dev,ci]
```

```bash
pre-commit install
```

You can run pre-commit before a commit with:

```bash
pre-commit run
```

## Commitizen

### Bump Version

```bash
cz bump --dry-run # first perform a dry run
cz bump
git push origin tag x.x.x
```

An alpha release can be created like this:
```bash
cz bump --prerelease alpha
```

### Push commit and tag atomically

For example, pushing the commit and tag for `v0.0.2-a1` would be done like this:
```bash
git push --atomic origin master v0.0.2-a1
```
