Giter Club home page Giter Club logo

rushcards's Introduction

Rush Cards

Sample Rush Cards puzzle

Rush Cards provides a Python command line application for generating puzzle cards for the game Rush Hour. It builds on a project by Michael Fogleman to identify all possible Rush Hour puzzles. Put simply, this project takes that database of puzzles, keeps the puzzles that can be expressed in the standard board game, maps a 1-10 difficulty scale onto them, and provides an interface to generate endless puzzle cards.

Installation

Make sure you have Python installed. Then run:

$ pip install rushcards

Usage

Cards are generated from the command line using either rushcards or python -m rushcards.

$ rushcards 5

This will generate a single card representing a random puzzle of difficulty 5, save the PNG image to a temporary directory, then open it in a native image-viewing application.

In addition to numbers 1 through 10 you can also specify _ (underscore) to choose a random difficulty.

To put multiple cards into the same image use a comma-separated list of difficulties.

$ # Create a single image with 6 puzzles in a 2x3 layout.
$ rushcards 2,_,4,5,6,10

A compact layout will be chosen automatically, but you can also specify the layout with the --layout option.

$ # Create an image with 6 rows of 1 puzzle each.
$ rushcards 2,_,4,5,6,10 --layout 6x1

Regardless of how the layout is chosen, enough puzzles will be generated to completely fill it. This is done by repeating the sequence of difficulties as many times as necessary.

$ # Create an image with 8 puzzles alternating between difficulties 2 and 3.
$ rushcards 2,3 --layout 2x4

Use the --outfile option to specify an output file.

$ # Save the image to a file.
$ rushcards 5 --outfile puzzle.png

Specify the file as - (hyphen) to output to stdout.

$ # Send the image to stdout and pipe it to another program.
$ rushcards 5 --outfile - | wc -c
7987

Note that when writing to stdout the image can't be opened automatically. You can also manually suppress opening the file with the --no-open option.

$ # Write the puzzle to a file but don't open it.
$ rushcards 5 --outfile puzzle.png --no-open

Notes

The puzzle cards do not show solutions. The puzzle database doesn't include them, and in any case they aren't really necessary to enjoy the game.

The pixel size of the PNG image is fixed to a fairly arbitrary value since image viewing applications all have the ability to scale as needed for viewing or printing.

This package also includes the mkpuzzles tool (invoked with python -m rushcards.tools.mkpuzzles). This was used to filter the original Rush Hour puzzle database, assign difficulties, and save the data for later use with the rushcards application.

In total the program can generate 443,266 distinct puzzles.

rushcards's People

Contributors

marfire avatar

Watchers

 avatar

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.