Then just fill in the rest of the grid with random letters (don't worry if they happen to spell other words, that's what the word list is there for -- to limit what the player is searching for). Be careful of not only single crosses, but double and higher crosses: see how applecrosses with both bananaand pearabove. Now the only confusing part is how the user will circle the words they've found!..*eww* Since it would be hard for the program to detect the user drawing circles on the screen, perhaps the user could merely enter the coordinates of the beginning character and indicate a direction/length/ending coordinate and the program would simply remove the word from their to find list (perhaps giving them points or something...).

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 12E: (Program) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question
100%

Language is C++

The purpose of this project is to test your ability to use files, strings (Strings?), and libraries effectively in program design.

A popular past-time is the word search puzzle (if you don't believe me, look in your daily paper and in the news stand in the check-out line at the grocery store). In such a puzzle, a grid of letters is presented which presumably contains words. However, the words are cleverly hidden among the other letters. Their camouflage is aided by them being aligned in many different orientations: horizontal, vertical, diagonal, and sometimes even backwards! The person's goal is to find the words and circle each one. Most often the person is also given a list of the words which should be found:

apple hananabs pear mpearoap banana npsgrape grape uleapnbm orange aenuraol agrafnel epanqust

bananais located backwards across the top row. appledrops down from the last ain bananapearis forwards from the first pin applegrapeis on the line below this. orangeis on a backwards diagonal crossinggrapeat the r.

You'd like to write a program to create such puzzles and let people play the game "virtually". (No, I'm not implying polymorphism...) You've got a file with plenty of words to choose from and you're fairly certain you can randomly choose words from the list and place them with other random characters in a grid.

What's that? Not sure how to place them in a grid with random characters? Well, the most obvious way to place the words in the grid is to simply choose a position and orientation at random, checking to see that any crosses occur at the same letter. If they do, place it. If not, select a new random position/orientation. Continue until you've placed the word or MAX_TRIESplacement attempts have failed (if you don't cap it, you may never end). So, given the word list (applepearbananagrape, and orange), you might place things like this:

apple ananab pear pearo banana p grape grape l a orange en g e

bananawas chosen for a backwards, sideways orientation and there was enough room. applewas chosen for a forwards, down orientation and happened to cross bananaat an apearwas chosen for forwards, sideways and crossed appleat a porangewas chosen for a backwards, back-diagonal and didn't cross anything (at the time). Finally, grapewas chosen for forwards, sideways and crossed orangeat the r.

Then just fill in the rest of the grid with random letters (don't worry if they happen to spell other words, that's what the word list is there for -- to limit what the player is searching for). Be careful of not only single crosses, but double and higher crosses: see how applecrosses with both bananaand pearabove.

Now the only confusing part is how the user will circle the words they've found!..*eww*

Since it would be hard for the program to detect the user drawing circles on the screen, perhaps the user could merely enter the coordinates of the beginning character and indicate a direction/length/ending coordinate and the program would simply remove the word from their to find list (perhaps giving them points or something...).

But then it can be confusing for the user to ignore that word if it isn't highlighted in some way. The simplest way would be to have everything begin in lowercase and then uppercase words which have been found. ...yeah, that's probably good enough.

So, in the above grid, after the user found the word orange, the program would display:

apple hananabs pear mpearOap banana npsgRape grape uleApnbm aeNuraol aGrafnel Epanqust

See how the found word now stands out from the surroundings? *sigh* Squint, then!

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning