5 Commits
Author SHA1 Message Date
cblanken 9b7b05f79d Fix min python version 2024-06-14 11:09:06 -04:00
cblanken 72f3d20401 Bump patch version 2024-06-14 10:36:21 -04:00
cblanken a611f4a7e7 Fixup board_randomizer typehints
Invalid `list[str]` type hints were causing errors in the downstream Boggler Flask app
2024-06-14 10:31:17 -04:00
cblankenandGitHub e183ce07c0 Update README.md 2024-04-13 10:19:20 -04:00
cblankenandGitHub 09e6f4a672 Update README.md
- Fix bad link to wordlists
- Add license link
2024-02-14 22:49:13 -05:00
3 changed files with 25 additions and 32 deletions
+5 -8
View File
@@ -18,7 +18,7 @@ To use the script to solve a Boggle board, you'll need to do a few things first.
d,f,e,y
n,m,e,qu
```
2. Find or create a dictionary wordlist file or create your own
2. Find or create a dictionary wordlist file
The dictionary wordlist should have each word on a single line like so
```console
@@ -44,7 +44,7 @@ To use the script to solve a Boggle board, you'll need to do a few things first.
3. Split the dictionary wordlist into separate files based on the first letter of each word.
To split an English wordlist the `split_wordlist_alpha.sh` script can be used like so:
To split an English wordlist, use the `split_wordlist_alpha.sh` script like so:
```console
$ split_wordlist_alpha.sh my_wordlist.txt .
```
@@ -97,7 +97,6 @@ BOARD
+---------------+
| O | W | H | A |
+---------------+
Starting @ (0, 0)
╭──────────┬──────────────────────────────────────────────────────────────────╮
│ Word │ Path │
@@ -142,8 +141,7 @@ BOARD
│ aia │ [(0, 1), (0, 2), (1, 2)] │
│ aias │ [(0, 1), (0, 2), (1, 2), (2, 3)] │
╰────────┴──────────────────────────────────────────────────╯
Starting @ (0,
2)
Starting @ (0,2)
╭──────┬──────╮
│ Word │ Path │
├──────┼──────┤
@@ -254,8 +252,7 @@ Starting @ (0,
│ yap │ [(1, 3), (1, 2), (0, 3)] │
│ yas │ [(1, 3), (1, 2), (2, 3)] │
╰──────┴──────────────────────────╯
Starting @ (2,
0)
Starting @ (2, 0)
╭──────┬──────╮
│ Word │ Path │
├──────┼──────┤
@@ -391,4 +388,4 @@ Navigate to the project root folder and run the following.
Run `poetry build`
# License
The included [wordlists](src/boggler/wordlists) are covered by their respective licenses. All other files MIT © Cameron Blankenbuehler
The included [wordlists](boggler/wordlists) are covered by their respective licenses. All other files [MIT](LICENSE) © Cameron Blankenbuehler
+11 -5
View File
@@ -1,8 +1,14 @@
"""Module to generate random Boggle boards for testing"""
from sys import argv, stderr
from random import randint, shuffle
from math import sqrt, floor
from pathlib import Path
from typing import List, TypeAlias
Die: TypeAlias = List[str]
Dice: TypeAlias = List[Die]
def read_dice_file(dice_path: Path):
@@ -11,17 +17,17 @@ def read_dice_file(dice_path: Path):
return [line.rstrip().split(",") for line in file.readlines() if line[0] != "#"]
def roll_die(die: str):
def roll_die(die: Die):
"""Return a face of the given die string to simulate rolling a die"""
return str(die[randint(0, len(die) - 1)])
def roll_dice(dice: list[str]):
def roll_dice(dice: Dice):
"""Return a random roll for each die"""
return [roll_die(die) for die in dice]
def get_random_board(dice: list[str]):
def get_random_board(dice: Dice):
shuffle(dice)
rolls = roll_dice(dice)
@@ -33,7 +39,7 @@ def get_random_board(dice: list[str]):
return board
def get_random_board_csv(dice: list[str]):
def get_random_board_csv(dice: Dice):
board = get_random_board(dice)
board = [",".join(row) for row in board]
return board
@@ -49,4 +55,4 @@ if __name__ == "__main__":
for r in range(0, int(floor(sqrt(len(dice))))):
print(board[r])
except Exception as e:
print("Argument must be a valid file path!", file=stderr)
print("Argument must be a valid file path.", file=stderr)
+9 -19
View File
@@ -1,32 +1,22 @@
[project]
name = "boggler"
version = "2.0.1"
authors = [
{ name="Cameron Blankenbuehler", email="cameron.blankenbuehler@gmail.com" },
]
description = "Utilities for solving the Boggle word game."
readme="README.md"
license = { file="LICENSE" }
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
]
[project.urls]
"Homepage" = "https://github.com/cblanken/boggler"
"Bug Tracker" = "https://github.com/cblanken/boggler/issues"
[tool.poetry]
name = "boggler"
version = "2.0.1"
version = "2.0.3"
description = "Utilities for solving the Boggle word game."
authors = ["Cameron Blankenbuehler <cameron.blankenbuehler@protonmail.com>"]
authors = ["Cameron Blankenbuehler <cameron.blankenbuehler@gmail.com>"]
license = "LICENSE"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
python = "^3.8"
rich = "^13.4.1"
[tool.poetry.scripts]