-2

Some of you may be familiar with the game called "BOGGLE".

Basically the game will display jumbled letters like this:

asdf  
wcrq  
nwoa  
erdf  

Then you need to look for all the possible answer in the board.
However I'm trying to develop a MOBILE GAME.
So here is what I'm planning:

I will ask the player to look for a SINGLE word in the given jumbled letters.

Example: look for the word CROWN in these letters:

asdf  
wcrq  
nwoa  
erdf  

Then I need to "trace" the answer CROWN out of this jumbled letters

But I don't know how I should implement that.

My problems are:

  1. How will the letters jumbled by itself and then at the same time the game can maintain the right answer?
  2. Every time the player traces the right answer, the next "look for the word" will display, then a new set of jumbled letters must be present
  3. If the player trace a right answer, the next "look for the word" SHOULD appear IMMEDIATELY thus TIME must be observed.
  4. The system must detect weather the player trace the right answer or not.

NOTE:
The player can trace to any direction he wants as long he won't jump to a letter to get the "look for the word."

Can you suggest algorithm and method or data structure to implement this?

I'm looking for a solution using HTML5, JavaScript and CSS.

Sample image:

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138

1 Answers1

1

Well, I would do iterative deepening with branch cutoff. For example:

1 2 3 4
5 6 7 8
9 0 A B
C D E F

There are 16 depth 1 nodes [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, A, B, C, D, E, F] and from any of them you can visit neighbor. For example If you choose 1:

* 2 3 4
5 6 7 8
9 0 A B
C D E F

List of depth 2 nodes would be [[1, 2], [1, 6], [1, 5]], then you check if your dictionary contains a word starting with any of them. If they do not then you can cut the branch! This is important, because otherwise there will be too much work to do. Lets assume [1, 2] did not exist and you picked [1, 6] :

* 2 3 4
5 * 7 8
9 0 A B
C D E F

List of depth 2 nodes would be [[1, 6, 2], [1, 6, 3], [1, 6, 7], [1, 6, A], [1, 6, 0], [1, 6, 9], [1, 6, 5]]. Like before you continue until you get to a node where there is no next move. Lets assume it is [1, 6, 2, 5]. Now you have longest word 4 letters long. After that you check if you get a longer word.

Depending on version you are playing you might want to adjust what result you take. For example in some versions you do not get extra points if you get a word longer then 8 letters - ex: if you find first 8 letter word you do not need to look further.

I hope this will get you started.

Margus
  • 19,694
  • 14
  • 55
  • 103
  • @user3610887 iterative deepening, I even added wikipedia link. – Margus May 07 '14 at 07:39
  • Your constraints are that you are looking for unique path with highest cost. I would not say this algorithm is the Best. It will be near best if you implement branch cutoffs well. Reason why I recommend this is that it is relatively easy to implement. – Margus May 07 '14 at 07:44
  • +1 for the good answer, kind of reminded me to the A* algorithm, in a way. – Nahuel Ianni May 07 '14 at 08:01
  • sir, can you name an algorithm ? – user3610887 May 07 '14 at 08:06