joshbduncan / word-search-generator

Make awesome Word Search puzzles!
MIT License
74 stars 24 forks source link

Why is there no difficulty 6 level? #66

Open neocogent opened 7 months ago

neocogent commented 7 months ago

Just curious if this is on purpose or an error in values array:

ValueError: 6 is not a valid difficulty number[1, 2, 3, 4, 5, 7, 8]

Seems odd...

Also it looks like difficulty 8 is an easy one not hard. All words go horz/vert no diags. I would have though it would be trickier than 7.

As a feature request I'd like to see some option for sharing letters. I think that's generally considered a good sign in word searches, though I may be mistaken. Not a word search expert but I have seen people complain when no sharing letters makes it too easy. So maybe over a given level it may enable that?

Thanks for a great tool!

joshbduncan commented 7 months ago

Initially,only level 1, 2, and 3 existed. The other levels were added by a contributor was using the package for generating crossword puzzles. They should probably be changed and order in some way that makes sense.

When you say "sharing letters", do you mean overlapping letters? Like "cat" and "bat" overlapping diagonally so they "share" the "a". If so, the generator definitely allows for that already (in all directions). If you aren't seeing that, please let me know.

Thanks for checking out the project!

nicolesimon13 commented 7 months ago

"The other levels were added by a contributor was using the package for generating crossword puzzles. " - is there a level that allows for creating crossword puzzles? Because I can only see level one which still makes words touching or overlapping, not like a true criss cross puzzle with 'spaces' in between them. https://www.pinterest.de/pin/859976491357596960/ shows an example

As for sharing letters - this goes into a similar thing like it did with my diagonal thing. @neocogent: you can write your own test of the grid if there is overlap of the words and otherwise do another puzzle. that way you can also control how many of them are there. like "write grid with answers and check how often a cell is written into, if so +1, make sure whole puzzle is at least ...".

joshbduncan commented 7 months ago

@nicolesimon13, no, there is no level that allows for creating crossword puzzles. Crossword puzzles have different properties than a word search puzzle that inky adjusting the level would satisfy. This is the exact reason I rewrote the package, allowing for anyone to write their own generator. A crossword generator "could" force a certain amount of overlapping words, leave out the filler characters, and would need to track the clues, along with some other stuff I'm sure I am not thinking out. You would also need to write a formatter for properly displaying with crossword with the numbering for clues.

neocogent commented 7 months ago

I haven't properly checked puzzles for shared letters but I may do some analysis soon. I have only output a relatively few number and it seemed like I could find no instance where they shared.

Perhaps I am not adding enough words for a given size puzzle. For example, I've been mostly trying 21 row/col puzzles with 25 words. That doesn't seem very dense but what is typical for word searches you would find in newspapers?

joshbduncan commented 7 months ago

@neocogent, yes you have it correct. It's simply a density problem. Then placing a word, the base generator picks random spots in the puzzle grid and checks if they are either empty or match the starting character of the word to place. If both of the checks pass, the generator then checks to ensure each letter of the word can be placed (using the same checks just mentioned) going in all possible directions. Then a random direction (from the directions that passed all checks) is picked and the word is placed.

So in a 21x21 puzzle, there are 441 available spots, and with 25 words (averaging a length of 7) there are a lot of potential random spots for the words to be placed. In this case, overlapping words are purely random.

Just so you can see it in action...

$ word-search cat bat -c -l 7 -s 5
WORD SEARCH
 ─────────
 T A S O Y
 C V T C H
 T A L B D
 B P T X U
 M M Q M O
 ─────────
Find words going SW, SE, NE, and, NW:
BAT, CAT

Answer Key: BAT NE @ (1, 4), CAT SE @ (1, 2)

$ word-search cat bat -c -l 7 -s 5
WORD SEARCH
 ─────────
 Y J D N Y
 S E T L S
 S A Q A Q
 C E K J B
 X G C E L
 ─────────
Find words going SW, SE, NW, and, NE:
BAT, CAT

Answer Key: BAT NW @ (5, 4), CAT NE @ (1, 4)

In the first run, the words share the letter "A", and in the second run, the words share the letter "T".

Even at 50 words in a 21x21 grid, I would say 50+ words would force some good overlap...

The latest version (still unreleased on PyPi) of the package that is available here on GitHub has abstracted the 'generator' away from the actual puzzle so you could write your own. When released, I plan to offer a few other generators along with the one currently implemented. One, I plan to work on will "force interactions/overlaps".

neocogent commented 7 months ago

Thanks. Makes sense.

duck57 commented 7 months ago

I believe I picked the numbers 4,5, 7, and 8 so that the keys for the difficulty dict would all be ints. I can't remember why I chose those specific numbers. In retrospect, some of them should have been assigned negative numbers to signal that they're probably not the ones you want for most puzzles.