7 Commits
Author SHA1 Message Date
cblanken a80111072f Bump release version 2022-12-30 20:55:44 -05:00
cblanken fa01d442a5 Fix bug in board randomizer
- The board randomizer did not account for dice files that don't contain an exact integer squared number of dice. For example the 5x5 dice file contains 26 possible dice since 1 extra die is provided.
- The fix takes the square root of the number of dice and takes the floor of that number as the total number of dice to choose.
2022-12-30 19:54:00 -05:00
cblanken 733c1474b0 Add 5x5 dice file 2022-12-30 19:51:41 -05:00
cblanken 54f79c0afe Remove dead code from boggler.py 2022-11-16 20:37:30 -05:00
cblanken 9f364ee90e Remove old dictionary word prefix lists 2022-11-16 20:36:55 -05:00
cblanken e219954ba6 Add function to flatten boggle board results into 1D list 2022-10-10 12:00:42 -04:00
cblanken f4accfe959 Update wordlist splitting script
- use ripgrep to exclude proper nouns (with capitals) output only the
  capture group
2022-09-28 13:01:39 -04:00
9 changed files with 67 additions and 58775 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "boggler"
version = "2.0.0"
version = "2.0.1"
authors = [
{ name="Cameron Blankenbuehler", email="cameron.blankenbuehler@gmail.com" },
]
+4 -4
View File
@@ -1,7 +1,7 @@
'''Module to generate random Boggle boards for testing'''
from sys import argv, stderr
from random import randint, shuffle
from math import sqrt
from math import sqrt, floor
from os import path
def read_dice_file(dice_path: str):
@@ -22,7 +22,7 @@ def get_random_board(dice: list[str]):
rolls = roll_dice(dice)
# Format dice rolls for boards file
board_size = int(sqrt(len(rolls)))
board_size = int(floor(sqrt(len(rolls))))
board = []
for i in range(0, len(dice), board_size):
board.append(rolls[i:i+board_size])
@@ -40,8 +40,8 @@ if __name__ == '__main__':
try:
dice = read_dice_file(path.abspath(argv[1]))
board = get_random_board_csv(dice)
for row in board:
print(row)
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)
+9
View File
@@ -2,6 +2,8 @@
from __future__ import annotations
from os import path
from multiprocessing import Pool
import functools
import operator
class BoardCell:
'''Boggle Board cell'''
@@ -418,3 +420,10 @@ def read_boggle_file(file):
'''Return list of rows from Boggle board csv file'''
with open(file, 'r', encoding='utf-8') as file:
return [x.rstrip().split(',') for x in file.readlines()]
def find_paths_by_word(board_letters, dictionary_path, max_len):
'''Return list of paths by word'''
boggle_board = BoggleBoard(board_letters, max_len)
boggle_tree = build_full_boggle_tree(boggle_board, dictionary_path)
paths_by_word = functools.reduce(operator.iconcat, [x.word_paths for x in boggle_tree.values()], [])
return paths_by_word
+27
View File
@@ -0,0 +1,27 @@
# Listed alphabetically
a,a,a,f,r,s
a,a,e,e,e,e
a,a,f,i,r,s
a,d,e,n,n,n
a,e,e,e,e,m
a,e,e,g,m,u
a,e,g,m,n,n
a,f,i,r,s,y
an,er,he,in,qu,th
b,j,k,qu,x,z
c,c,e,n,s,t
c,e,i,i,l,t
c,e,i,l,p,t
c,e,i,p,s,t
d,d,h,n,o,t
d,h,h,l,n,o
d,h,l,n,o,r
d,l,o,h,h,r
e,i,i,i,t,t
e,m,o,t,t,t
e,n,s,s,s,u
f,i,p,r,s,y
g,o,r,r,v,w
i,k,l,qu,u,w
n,o,o,t,u,w
o,o,o,t,t,u
1 # Listed alphabetically
2 a,a,a,f,r,s
3 a,a,e,e,e,e
4 a,a,f,i,r,s
5 a,d,e,n,n,n
6 a,e,e,e,e,m
7 a,e,e,g,m,u
8 a,e,g,m,n,n
9 a,f,i,r,s,y
10 an,er,he,in,qu,th
11 b,j,k,qu,x,z
12 c,c,e,n,s,t
13 c,e,i,i,l,t
14 c,e,i,l,p,t
15 c,e,i,p,s,t
16 d,d,h,n,o,t
17 d,h,h,l,n,o
18 d,h,l,n,o,r
19 d,l,o,h,h,r
20 e,i,i,i,t,t
21 e,m,o,t,t,t
22 e,n,s,s,s,u
23 f,i,p,r,s,y
24 g,o,r,r,v,w
25 i,k,l,qu,u,w
26 n,o,o,t,u,w
27 o,o,o,t,t,u
+26 -26
View File
@@ -4,32 +4,32 @@ if [ -z $1 ] || [ -z $2 ]; then
echo "Usage: WORDLIST OUT_DIR"
exit 0
else
grep -ioP "^a[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_a.txt"
grep -ioP "^b[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_b.txt"
grep -ioP "^c[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_c.txt"
grep -ioP "^d[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_d.txt"
grep -ioP "^e[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_e.txt"
grep -ioP "^f[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_f.txt"
grep -ioP "^g[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_g.txt"
grep -ioP "^h[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_h.txt"
grep -ioP "^i[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_i.txt"
grep -ioP "^j[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_j.txt"
grep -ioP "^k[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_k.txt"
grep -ioP "^l[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_l.txt"
grep -ioP "^m[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_m.txt"
grep -ioP "^n[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_n.txt"
grep -ioP "^o[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_o.txt"
grep -ioP "^p[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_p.txt"
grep -ioP "^q[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_q.txt"
grep -ioP "^r[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_r.txt"
grep -ioP "^s[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_s.txt"
grep -ioP "^t[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_t.txt"
grep -ioP "^u[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_u.txt"
grep -ioP "^v[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_v.txt"
grep -ioP "^w[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_w.txt"
grep -ioP "^x[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_x.txt"
grep -ioP "^y[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_y.txt"
grep -ioP "^z[a-z]+" $1 | tr [A-Z] [a-z] | sort | uniq > "$2/words_z.txt"
rg "(^a[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_a.txt"
rg "(^b[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_b.txt"
rg "(^c[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_c.txt"
rg "(^d[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_d.txt"
rg "(^e[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_e.txt"
rg "(^f[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_f.txt"
rg "(^g[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_g.txt"
rg "(^h[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_h.txt"
rg "(^i[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_i.txt"
rg "(^j[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_j.txt"
rg "(^k[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_k.txt"
rg "(^l[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_l.txt"
rg "(^m[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_m.txt"
rg "(^n[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_n.txt"
rg "(^o[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_o.txt"
rg "(^p[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_p.txt"
rg "(^q[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_q.txt"
rg "(^r[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_r.txt"
rg "(^s[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_s.txt"
rg "(^t[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_t.txt"
rg "(^u[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_u.txt"
rg "(^v[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_v.txt"
rg "(^w[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_w.txt"
rg "(^x[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_x.txt"
rg "(^y[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_y.txt"
rg "(^z[a-z]+).*$" -or '$1' $1 | sort | uniq > "$2/words_z.txt"
touch "$2/words__.txt"
exit 0
fi
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff