bunkat / wordfind

A small javascript library for generating and solving word find (also known as word search) puzzles.
MIT License
196 stars 111 forks source link

preferOverlap not working as expected. #6

Open MrJoshFisher opened 8 years ago

MrJoshFisher commented 8 years ago

Hello, I've set preferOverlap to false, within the wordfind.js file but its still overlapping when generating the wordsearch, am I missing something or am I suppose to put preferOverlap somewhere else?

bunkat commented 8 years ago

That setting will try to maximize the amount of overlap in the puzzle. There isn't currently a setting to eliminate overlap. Setting preferOverlap to false just means it will randomly select from all possible valid positions found. If you try and eliminate overlap the puzzle might take a long time to generate.

However, if that's what you want it wouldn't be too hard to do. Just look in the code where preferOverlap is used and select the position with zero overlap instead or fail the placement. The puzzle size will increase until a valid puzzle is found.

bunkat commented 8 years ago

Look at 'placeWordInPuzzle'. You'll want to filter the locations array to only pick ones where location.overlap === 0. Everything else should just work.

MrJoshFisher commented 8 years ago

Ahhh shame my crossword has multiple words that tend to overlap e.g copywriting, copy, writing. Is there a way to change the opacity of a word that overlaps so you could se on the word search that the words overlap if that makes sense.