wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Need help making a word search game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help making a word search game" Watch "Need help making a word search game" New topic
Author

Need help making a word search game

Jamie Rico
Greenhorn

Joined: Sep 27, 2012
Posts: 3
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

Joined: Mar 17, 2011
Posts: 7076
    
  16

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


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Jamie Rico
Greenhorn

Joined: Sep 27, 2012
Posts: 3
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

Joined: Oct 02, 2003
Posts: 10916
    
  12

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?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jamie Rico
Greenhorn

Joined: Sep 27, 2012
Posts: 3
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

Joined: Mar 17, 2011
Posts: 7076
    
  16

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help making a word search game
 
Similar Threads
Hangman type game
IDE or bust?
Proper way to show images, whose alignment is based on a condition
Reading text in a table from word document
June Newsletter Puzzle