Skip to content

A Python implementation of a Regex Crossword in the terminal.

License

Notifications You must be signed in to change notification settings

DivoK/regex_crossword

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Regex Crossword

License: MIT PyPI pyversions PyPI version fury.io Code style: black

Terminal Freaks rejoice!

Based on the Regex Crossword, this is an implementation written in pure python using only the standard library to play the game offline entirely from your shell.

If you aren't familiar with the concpet of a regex crossword, it's a blank crossword grid that you need to fill so that each row and column will match the specified regex. It's a fun exercise to your regex abilities and an interactive way to learn about them and practice while playing.

I'm a bit of a terminal freak myself and so the moment I started playing the wonderful online version it seemed so natural to me that there needs to be a version of the concept playable from the shell, so I made one using nothing but Python's curses module.

Installation

Use the Python package manager pip to install regex_crossword.

pip install regex_crossword

To install the scraper functionality as well (more on this below) use:

pip install regex_crossword[scraper]

Note: the scraper uses the Selenium 3rd party package that might need extra setup to be used (specifically the Chrome WebDriver). If you encounter any problems I advise you to check out their installation guide.

Usage

Once installed in your environment, simply type regex_crossword from your terminal and start playing!

Loading level packs

When the game starts it will attempt to load "level packs" for it to use. It looks for them in the following places in descending order:

  1. First, it will look wherever the --level-packs option was pointing when invoking the game command (for a full list of all commands use the -h or --help flag).
  2. If no option was specified, it will look wherever the REGEXCW_LEVEL_PACKS environment variable is pointing, if it exists.
  3. Lastly and by default, it will search for a directory called level_packs in the current working directory.

If all of this fails (or the directory has no packs), an error will pop up informing you no level packs were found.

Getting level packs

When trying to get level packs you have several options:

  • Use the --scrape flag (this requires you to install the scraper extra). This will scrape some online resources and create level packs based on them for you to load into the offline version.
  • Create your own level packs!

Creating your own level packs

Level packs are simply JSON files who follow this format:

[
    {
        "title": "Beatles",
        "up_to_down": [
            "[^SPEAK]+",
            "EP|IP|EF"
        ],
        "left_to_right": [
            "HE|LL|O+",
            "[PLEASE]+"
        ],
    },
    {
        "title": "Pisco Sour",
        "up_to_down": [
            "(MA|LM)",
            "[^MESH]+"
        ],
        "left_to_right": [
            "[LINE]+",
            "[LAM]+"
        ],
        "right_to_left": [
            "[ISLE]+",
            "[MALE]+"
        ],
        "down_to_up": [
            "[LAME]*",
            "[^LES]+"
        ]
    },
]

The main file json is a list of smaller dictionaries who each implement a "level" format:

  • title - the title of the level.
  • up_to_down - the regexes who will attempt to match the columns from top to bottom (specified from left to right)
  • left_to_right - the regexes who will attempt to match the rows from left to right (specified from top to bottom)
  • down_to_up - same as up_to_down but will attempt to match the columns from bottom to top.
  • right_to_left - same as left_to_right but will attempt to match the rows from right to left.

License

MIT

About

A Python implementation of a Regex Crossword in the terminal.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages