Fun & Games | Wordsearches | Crosswords | Quizzes | Hangman

Hunting the Whale Wordsearch

From the HistoryShelf web site: <www.historyshelf.org>

Here's a word search you can print out. The words can run in any direction, up, down, diagonally, forwards or backwards. The word search is newly created for each visitor to the site, so although the words you need to find are always the same, they are in different places every time.

Your name:

Date:

0,y=>1);// up | $dirtn[1]=array(x=>1,y=>0);// right - $dirtn[2]=array(x=>0,y=>-1); // down | $dirtn[3]=array(x=>-1,y=>0); // left - $dirtn[4]=array(x=>1,y=>1);// up and right / $dirtn[5]=array(x=>1,y=>-1); // down and right \ $dirtn[6]=array(x=>-1,y=>-1); //down and left / $dirtn[7]=array(x=>-1,y=>1); //up and left \ //establish board with blank spaces for ($i=0;$i!=$gridsize;$i++){ for ($j=0;$j!=$gridsize;$j++){ $board[$i][$j]= " "; } } } // ------------------------------------------------------------------------------------------ function placewords(){ global $studentname,$classname,$assignment,$period,$board,$wordarray,$dirtn,$title,$gridsize,$wordlist,$difficulty,$listorder,$HTTP_POST_VARS; // count the number of letters in the first word $wordnumber=count($wordarray); // main for loop one time through for each word for($i=0;$i!=$wordnumber;$i++) { // count the letters in the current word $letternumber=(count($wordarray[$i])); // toggle wordfit for verification of word fitting on the grid without overwriteing any other letters $wordfit=0; while ($wordfit <= 0){ // toggle wordfit again in case the while loop runs a few times $wordfit=0; // toggle length ok to ensure proper checking of word length within constraints of grid $lengthok=0; // test for fit of word while ($lengthok!=1){ // seed random with the clock srand((double)microtime()*1000000); // get the random direction based on difficulty selected switch ($difficulty){ case hard: $direction=rand()%8; break; case easy: $direction=rand()%4; break; default: $direction=rand()%8; } // pick a random position within the scope of the grid srand((double)microtime()*1000000); $position=array(x=>(rand()%$gridsize),y=>(rand()%$gridsize)); // calculate where the word will end $endposition[x]=$position[x]+($letternumber*$dirtn[$direction][x]); $endposition[y]=$position[y]+($letternumber*$dirtn[$direction][y]); // make our endposition calculation have to be between 0 and 1 $result[x]=(abs($endposition[x]/$gridsize)); $result[y]=(abs($endposition[y]/$gridsize)); // if the end position is inside the grid set the length ok if($result[x]>1) { $lengthok=0; } elseif($result[y]>1) { $lengthok=0; } else{ $lengthok=1; } } // set a temp var to verify every position a letter will occupy $tposition=$position; // now check for what is in the positions selected reset($wordarray[$i]); while ( list ($key,$val)=each($wordarray[$i])){ // what is currently in the space switch ($board[$tposition[x]][$tposition[y]]){ // if it is a space, move in the direction one space and toggle wordfit +1 case " ": $tposition[x]=$tposition[x]+$dirtn[$direction][x]; $tposition[y]=$tposition[y]+$dirtn[$direction][y]; $wordfit=$wordfit+1; break; // if it is the same as the value we want to place there, move and toggle wordfit +1 case $val: $tposition[x]=$tposition[x]+$dirtn[$direction][x]; $tposition[y]=$tposition[y]+$dirtn[$direction][y]; $wordfit=$wordfit+1; break; // if the letter is not compatible, toggle wordfit -50 so that we do not place the word // we will have to go back and find a new place default: $wordfit=(-50); } } } reset ($wordarray[$i]); // we have successfully gotten out of the first while loop and the word can be placed while (list ($key,$val)=each($wordarray[$i])){ $board[$position[x]][$position[y]]=$val; $position[x]=$position[x]+$dirtn[$direction][x]; $position[y]=$position[y]+$dirtn[$direction][y]; } } // end of main for loop } //------------------------------------------------------------------------------------ function printgrid(){ global $studentname,$classname,$assignment,$period,$board,$wordarray,$dirtn,$title,$gridsize,$wordlist,$difficulty,$listorder,$HTTP_POST_VARS; //fill blanks with random characters reset($board); // while in each row x while (list($key,$val)=each($board)){ // go to each column y while (list($key2,$val2)=each($board[$key])){ // if the character there is blank go ahead and fill it in in the array switch ($board[$key][$key2]){ case " ": srand((double)microtime()*1000000); $board[$key][$key2]=chr(rand()%26+65); break; default: break; } } } // now print those values to the page inside of a table for ($i=0;$i!=$gridsize;$i++){ echo "\n"; for ($j=0;$j!=$gridsize;$j++){ echo "" . $board[$i][$j] . "\n"; } echo "\n"; } } // ----------------------------------------------------------------- function printlist(){ global $studentname,$classname,$assignment,$period,$board,$wordarray,$dirtn,$title,$gridsize,$wordlist,$difficulty,$listorder,$HTTP_POST_VARS; sort ($wordlist); reset ($wordlist); while (list ($key,$val)=current( $wordlist) ) { echo "\n"; for ($i=0;$i<4;$i++){ $val=current($wordlist); echo "

" . $val . "

\n"; $val=next($wordlist); } echo "\n"; } } // ----------------------------------------------------------------- ?>



Original WordSearch script by Park Wiker <www.wiker.net>

 Skip to Navigation