bunkat/wordfind

preferOverlap not working as expected.

MrJoshFisher opened this issue · 3 comments

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?

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.

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

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.