A Python implementation of a Regex Crossword in the terminal.
Project description
Regex Crossword
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:
- 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). - If no option was specified, it will look wherever the
REGEXCW_LEVEL_PACKS
environment variable is pointing, if it exists. - 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 thescraper
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 asup_to_down
but will attempt to match the columns from bottom to top.right_to_left
- same asleft_to_right
but will attempt to match the rows from right to left.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file regex_crossword-0.1.0.tar.gz
.
File metadata
- Download URL: regex_crossword-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12a64b5e0f1a2a78793707d8fb65184be6908f5c8b81f3602925892dfaa761ba |
|
MD5 | 44e50fe32cd43bd7c58f8fd96d652d3e |
|
BLAKE2b-256 | 6c8c9ad49310099099c5ecb5d70a39f66161a9eea9d0699b226c442bb3f48cab |
File details
Details for the file regex_crossword-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: regex_crossword-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3687eb3040de38920fa95139b0811038caf83aa176900c2ec59c0beb68e61848 |
|
MD5 | 222e5325bba75d777a967470243ef75f |
|
BLAKE2b-256 | a35b884afcb245013b80fad21368593f1a65046b6c6e0d5900ce63a935103280 |