src/lib/wordfind.js
function (puzzle, options, word) {
            // find all of the best locations where this word would fit
            var locations = findBestLocations(puzzle, options, word);
            if (locations.length === 0) {
                return false;
            }
            // select a location at random and place the word there
            var sel = locations[Math.floor(Math.random() * locations.length)];
            placeWord(puzzle, word, sel.x, sel.y, orientations[sel.orientation]);
            return true;
        }
function (puzzle, options, word) {
            // find all of the best locations where this word would fit
            var locations = findBestLocations(puzzle, options, word);
            if (locations.length === 0) {
                return false;
            }
            // select a location at random and place the word there
            var sel = locations[Math.floor(Math.random() * locations.length)];
            placeWord(puzzle, word, sel.x, sel.y, orientations[sel.orientation]);
            return true;
        }
function ( puzzle , options , word ) { // find all of the best locations where this word would fit var locations = findBestLocations ( puzzle , options , word ) ; if ( locations . length === 0 ) { return false ; } // select a location at random and place the word there var sel = locations [ Math . floor ( Math . random ( ) * locations . length ) ] ; placeWord ( puzzle , word , sel . x , sel . y , orientations [ sel . orientation ] ) ; return true ; }
Adds the specified word to the puzzle by finding all of the possible
locations where the word will fit and then randomly selecting one. Options
controls whether or not word overlap should be maximized.

Returns true if the word was successfully placed, false otherwise.

@param {[[String]]} puzzle: The current state of the puzzle
@param {[Options]} options: The options to use when filling the puzzle
@param {String} word: The word to fit into the puzzle.
Adds the specified word to the puzzle by finding all of the possible locations where the word will fit and then randomly selecting one . Options controls whether or not word overlap should be maximized .