bunkat/wordfind

Not Working

johnstew opened this issue · 6 comments

I am trying to demo this but it is not letting me find a word when I drag. Any idea as to whats going on?

Is this browser specific? or should it work on all browsers?

Looks like the demo that I wrote only works with Chrome and Firefox currently. I didn't really spend that much time testing it out since it was only for an example of the library.

Can you summarize the entire program in an algorithm?

Sure.

  • Create an array of words to use in the puzzle
  • Sort the words in descending order by length. Longer words are harder to place and so we want to place those first
  • Create an empty board of size height x width where height and width are equal to the longest word in the list
  • For each word in the word list
    • Loop through each square in the board
      • Check if the square is empty or is equal to the first letter of the word
      • If not, move to the next square
      • If yes, check the adjacent squares to the right to see if they are equal to the second letter of the word
        • Continue checking adjacent squares to the right until either a square is not valid, or the word ends
        • If the word fits, add it to the list of possible locations for this word along with the direction
      • Check all valid directions starting from this square in a similar manner
    • If the list of possible locations is empty, create an empty larger board and try again
    • If the list of possible locations is not empty, either:
    • Select a location randomly and place the word in that location (less compact puzzle)
    • Track the number of squares that were not empty for each location and select the location randomly from those with the most non-empty squares (more compact puzzle)
  • Fill any empty squares with randomly selected letters

thank you so much! 👍

Another thing. Since I am extremely new to javascript, I am not able to make out, in which function is the grid being made and that in which the found words are stuck off. :(

is there any call back on completion of quiz???