Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Need help making a word search game

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
lowercase baba
Posts: 13074
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic