Rummikub Solver library
Fast and flexible Rummikub solver library, written in Python, to find the best options for placing tiles from a player's rack on to the table.
The algorithm used builds on the approach described by D. Den Hertog, P. B. Hulshof (2006), "Solving Rummikub Problems by Integer Linear Programming", The Computer Journal, 49(6), 665-669 (DOI 10.1093/comjnl/bxl033).
Features
- Can work with different Rummikub variations, letting you adjust the number of colours, tiles, and other aspects
- You can freely adjust what tiles are on the rack or on the table, within the limits of what tiles are available according to the current rules
- Can be used with any of the Mixed-Integer Linear Programming (MILP) solvers supported by cvxpy.
Solver improvements
The original models described by Den Hertog and Hulshof assume that all possible sets that meet the minimum length requirements and can't be split up are desirable outcomes.
However, any group set (tiles with the same number but with different colours) containing at least one joker, but which is longer than the minimal run, in effect contains a redundant joker, something you wouldn't want to leave on the table for the next player to use. The same applies to run sets (tiles of the same colour but with consecutive numbers), that are longer than the minimal set length but start or end with a joker. In this implementation, such sets are omitted from the possible options.
The implementation also includes a solver for the initial move, where you can only use tiles from your own rack and must place a minimum amount of points before you can use tiles already on the table. This solver is a variant of the original solver that maximizes tiles placed, but is constrained by the minimal point amount and disregards jokers (which means jokers are only used for the opening meld if that is the only option available).
Documentation
See the project documentation for details.
Install
You can install this project the usual way. e.g. with pip:
$ pip install rummikub-solver
or with uv:
$ uv add rummikub-solver
Picking an alternative solver backend
This library builds on cvxpy to define the Rummikub models, which can then be solved using any of the supported MILP solver backends. By default, the SCIPY backend is used, which in turn uses a version of the HiGHS optimizer that comes bundled with SciPy.
You can also install an alternative Open Source solver backends via extras:
| Extra | Backend | License | |
|---|---|---|---|
cbc |
COIN-OR Branch-and-Cut solver | EPL-2.0 | |
glpk_mi |
GNU Linear Programming Kit | GPL-3.0-only | Installs the cvxopt project |
highs |
HiGHS | MIT | Arguably the best OSS MILP solver available. This installs a newer version of HiGHS than what is bundled with SciPy. |
scip |
SCIP | Apache-2.0 |
You can also pick from a number of commercial solvers; no extras are provided for these:
COPT: Cardinal Optimizer, https://github.com/COPT-Public/COPT-ReleaseCPLEX: IBM CPLEX, https://www.ibm.com/docs/en/icosGUROBI: Gurobi Optimizer, https://www.gurobi.com/MOSEK: https://www.mosek.com/XPRESS: Fico XPress,, https://www.fico.com/en/products/fico-xpress-optimization
Refer to their respective documentations for installation instructions.
When HiGHS is installed, it is automatically used as the default solver.
Development
The source code for this project can be found on GitHub.
When running locally, install uv, then run:
$ uv run rsconsole
to run the console solver. A Taskfile is provided that defines specific tasks such as linting, formatting or previewing the documentation:
$ task --list
task: Available tasks for this project:
* default: Default task, runs linters and tests
* dev:format: Runs formatters (aliases: format)
* dev:install-precommit: Install pre-commit into local git checkout
* dev:lint: Runs linters (aliases: lint)
* dev:lint:code: Lint the source code
* dev:lint:renovate: Lint the Renovate configuration file
* dev:test: Run tests (aliases: test)
* dev:uv-lock: Updates the uv lock file (aliases: lock)
* dist:build: Build the distribution packages (aliases: dist)
* dist:clean: Remove built distribution packages (aliases: clean)
* dist:publish: Publish package to PyPI (aliases: publish)
* docs:build: Build project documentation (aliases: docs)
* docs:serve: Live preview server for project documentation (aliases: preview)
Credits
The initial version of the solver was written by Ollie Hooper.
This version is a complete rewrite by Martijn Pieters, to improve performance and address shortcomings in the original paper.
Metadata
Release files for rummikub-solver 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rummikub_solver-1.0.0.tar.gz | 94.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rummikub_solver-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 114.7 kB
Release files / rummikub_solver-1.0.0.tar.gz
| Download URL | rummikub_solver-1.0.0.tar.gz |
|---|---|
| Size | 94.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b35ae1b3cb1bf9da3b58eb56a5e657b7713b3a263752e3767946e4be1ff54a9
|
|
BLAKE2b-256 checksum How to use checksums |
3b0f0e5bf490076c45be061ce1cafd8a9b3a3529458ed252c3c1fc1458966cbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 28, 2025.
Transparency logRelease files / rummikub_solver-1.0.0-py3-none-any.whl
| Download URL | rummikub_solver-1.0.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27ae2bcd275c5186570d4efdc36262712a63aaa34c6609e37550b94ac6a3a6e3
|
|
BLAKE2b-256 checksum How to use checksums |
1407b79a41f7c986f1cf12848ac38cc409e2c344c89083d18164cac6781d902c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 28, 2025.
Transparency log