Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help making a word search game

 
Jamie Rico
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I have a project where I need to make a word search game and I am completely lost.
These are the steps I think I should take, does it sound correct?
Read in the file that has the wordsearch and the guesses
ex
10 10
WVERTICALL
ROOAFFLSAB
ACRILIATOA
NDODKONWDC
DRKESOODDK
OEEPZEGLIW
MSIIHOAERA
ALRKRRIRER
KODIDEDRCD
HELWSLEUTH
10
WEEK
FIND
RANDOM
SLEUTH
BACKWARD
VERTICAL
DIAGONAL
WIKIPEDIA
HORIZONTAL
WORDSEARCH

The first two numbers are rows and columns followed by the wordsearch followed by how many words are in the search, lastly followed by the guesses.
The program is supposed to print out the location of the first letter of the word using (rows,columns) coordinates.

After I read the file in, what should be my next step?
I think it should be putting the wordsearch into an array but I am not sure.
Any help?

Thank you so much
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jamie Rico wrote:I think it should be putting the wordsearch into an array but I am not sure.

Sounds reasonable to me. Probably something like a char[10][10] or maybe even a String[10] (which may have a few advantages).

But before you do any of that, sit down with a piece of paper and a pencil, draw your wordsearch grid, and try things out for yourself.

What are the rules? Does the word have to be found in a single row, or can you find it diagonally? Can you find it backwards?

How do you think you should go about finding words? When can you stop? Unfortunately, our brains are quite sophisticated, so we can often just "see" things without having to think them through. A computer can't, and it doesn't have eyes.

I'd start with one guess word at a time and then work up. And only go back to Java only when you're sure you understand how to handle your searches. And by all means, come back and try out your logic on us.

HIH

Winston
 
Jamie Rico
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The words can be found forward, vertically, and diagonally.
I am not sure what you mean by try things out myself.

I have the file scanned in the correct way I believe


I am not sure how to put it into a 10x10 that is searchable.

Once in the array I would run a search for the first letter of the first word, once it finds a match it would search for the second letter below, in front or diagonally down and right. Then continue in the direction it found the next letter, or move on to keep searching if no matches were found.

Am I on the right track?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12127
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jamie Rico wrote:I am not sure what you mean by try things out myself.

What he means by that is STOP WRITING CODE. instead, write down IN ENGLISH how YOU would solve a puzzle like this. For example, something like this:

Get the grid of letters
get the list of words
pick the next word off the list
search for that word in the grid until it is found or we exhaust the list
continue until there are no more words

All of this is fairly straightforward, except for #4. So now start revising #4. How would you find this word if all you had was pencil and paper?

 
Jamie Rico
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get the grid of letters
get the list of words
pick the next word off the list
search for that word in the grid until it is found or we exhaust the list
continue until there are no more words


I have that written down. I have
1. Make grid of letters
2.Read list of words
3.Search for word one by searching letter by letter
4.Move onto next word
5.Repeat 3-4 until no words left

Logically I know what I need to do. It is implementing it into code.

 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jamie Rico wrote:Logically I know what I need to do. It is implementing it into code.

Actually, you don't. There's a whole pile of logic missing from #3, and it's that that you need to be clear about.

How do you search for Word 1 letter-by letter?
EXACTLY.

And don't write a line of code in Java until you can describe it in English (or your native language).

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic