Git Product home page Git Product logo

rummikubconsole's Introduction

Rummikub Console

A Rummikub solver console supporting multiple games and persistence, written in Python.

screenshot of a macOS terminal window with a Rummikub Console session in progress

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 track multiple games, letting you switch between named games
  • Saves tracked games automatically
  • Can work with different Rummikub rules, 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

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).

Install

You can install this project the usual way:

$ pip install RummikubConsole

or use a tool like pipx to help you manage command-line tool installations like these:

$ pipx install RummikubConsole 

Usage

Run the rsconsole command-line tool to open the console, or run rsconsole --help to see how you can adjust the Rummikub rules (you can adjust tile count, colours, joker count, the minimum number of tiles to make a set and the minimum score for the initial placement).

You then enter the console command loop. Enter ? or h or help to list the available commands, and help <command> to get help on what each command does.

Development

The source code for this project can be found on GitHub.

When running locally, install Pipenv, then run:

pipenv install
pipenv run rsconsole

to run the console solver.

Credits

The initial version of the solver and console were written by Ollie Hooper.

This version is a complete rewrite by Martijn Pieters, with new console implementation, expansion of the solver to improve performance and address shortcomings in the original paper, as well as multi-game, game state tracking and persistence support.

rummikubconsole's People

Contributors

mjpieters avatar ollie-hooper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

jamalbendadi

rummikubconsole's Issues

Cannot install on macOS 13.0

Hello, is there an alternate way to install?

I have tried using pip and pipx but neither yielding the install. I keep running into an issue with what may be architecture related.
$ pip install RummikubConsole

Error I am running into:
Screenshot 2022-11-07 at 10 33 35

Are you aware of this clang error is there a way around it for me? Let me know what other info I need to provide to assist you.

MacBook Pro 14" M1 Max 32gb Ram
macOS Ventura 13.0 (22A380)
pip 22.3.1 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)

Non-printable escapes for readline break ANSI color codes on Windows

I noticed that I get extra characters/emojis around the game name when I use it on Windows.
(rsconsole) [☺☻default☺☻ ☺☻☒☺☻]
When I change the variables N1 and N2 in the code, it still works and the extra characters disappear. Is this a windows only thing?

Joker group and run cull was too drastic

We need to add back longer-than-min-length runs with jokers back, but only generate new sets with the outer tiles kept.

So something like sorted((s[0], *comb, s[-1])) for comb in combinations((*s[1:-1], *jokers), ln) for ln in range(min_len - 1, min_len * 2 - 2)

Click 8.1.0 removed get_terminal_size, should use shutil.get_terminal_size instead.

Here is the error I get when I enter any command in prompt :

(rsconsole) [default ☒]
Traceback (most recent call last):
  File "/usr/local/bin/rsconsole", line 8, in <module>
    sys.exit(rsconsole())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rummikubconsole/__main__.py", line 79, in rsconsole
    cmd.cmdloop()
  File "/usr/local/Cellar/[email protected]/3.9.14/Frameworks/Python.framework/Versions/3.9/lib/python3.9/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/local/Cellar/[email protected]/3.9.14/Frameworks/Python.framework/Versions/3.9/lib/python3.9/cmd.py", line 204, in onecmd
    return self.emptyline()
  File "/usr/local/lib/python3.9/site-packages/rummikubconsole/console.py", line 606, in do_solve
    self.message("No solution found - pick up a tile.")
  File "/usr/local/lib/python3.9/site-packages/rummikubconsole/console.py", line 278, in message
    twidth, theight = click.get_terminal_size()
AttributeError: module 'click' has no attribute 'get_terminal_size'`

Thanks.

Issues running rsconsole

Good day, I cannot seem to run rsconsole on my Mac

Install seems to go smooth without any errors but running rsconsole yields this unfortunate message:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.