Menu

(Solved) : Game Boggle Execute Like C Java Boggle Dictionarytxt 4x4txt Boggle Input File Test Expect Q37302185 . . .

THE GAME OF BOGGLE

EXECUTE LIKE THIS: C:> java Boggle dictionary.txt 4×4.txt(or any boggle input file)
this is how I will test it and will expect you use args[0] as thedictionary and args[1] as the input file

ONLY WORDS OF LENGTH 3 or MORE ARE TO BE COUNTED/OUTPUTTED

Solving the game of Boggle can be done elegantly with recursionand backtracking. Backtracking is a technique whereby an algorithmrecognizes it is impossible or unnecessary to search any deeperinto the search space from a given point. An example of this isfinding your way through a maze. When you hit a dead end youretreat from that point and never take the same path to that pointagain. A fast and efficient solution to Boggle requires a heuristicthat helps you recognize a dead end and save vast amounts of wastedwords formed and wasted searches (and thus vast amounts oftime).

Boggle is a board game that uses 16 dice arranged in a 4 x 4grid. There is also a 5×5 version. Each die has 6 faces with aletter of the alphabet on it. Occasionally the string “Qu” willappear on a dice face. A typical board might look like this.

Here is a development strategy you should follow which verifiesthe string generating component algorithm first before searchingthe dictionary, deploying a heuristic or building a GUI.

A typical Boggle game usually starts by shaking the dice on theboard thus creating a new grid of letters on the game board. Theobject of the game is for each player to form as many validdictionary words as possible by connecting adjacent letters in anydirection without any cycles. Think of how a King can move an achessboard – across, up, down or diagonal. You can generate wordsby connecting letters in any direction as long as you don’t createcycles. Thus in a 4×4 grid you could form words as long as 16characters (well.. 17 if you hit a “Qu” dice).

DON’T JUST CODE UP THE WHOLE PROGRAM. DEVELOP IT IN STAGES.STAGE#1 IS VERIFY STRING GENERATION

The first step of your program development should be to get yourDFS method to form and print/saveEVERY POSSIBLE word that can begenerated from the grid. Until you verify this you should not writeany more code.

The DFS method of Boggle is very similar to that of the swamp.Where the swamp tacks on the coordinates of the incoming steplocation, Boggle tacks on the letter at that coordinate. This ishow it grows the word by one letter with each call – just likeswamp grows the path by one step with each call. As soon as youtack on the letter of the incoming coordinates, add that word to aTreeSet of String named something like allPossWords or such. Afteryour DFS returns to main, then print out this list of words thatrepresent all possible words that can be formed from the inputtedgrid. Be sure to use the input files below and look for the wordsprinted by your DFS to match the set of words listed below thatshould be produced by that file. You only need to test on 2×2 and3x3.

You will be surprised at home many unique strings you cangenerate from even a 2 x 2 grid. A 2 x 2 grid can generate 64unique strings. A 3 x 3 can generate 10,305 and a 4 x 4 generatesover 12 million. A 5 x 5 generates over 115 billion. Larger gridsare astronomical. There is no known closed form expressionto calculate the number of strings that can be formed from an N x Ngrid.   The only way to calculate that number is togenerate all those strings with a program and count them as youform them.

This 2×2.txt grid produces this set of unique strings ==>2×2-64_WORDS.txt

This 3×3.txt grid produces this set of unique strings ==>3×3-10305_WORDS.txt

This 4×4.txt grid produces 12,029,640 unique strings

This 5×5.txt grid produces 115,066,382,913 unique strings

A Heuristic:

In order to avoid forming all possible strings to find the real(dictionary) ones, you will need a heuristic to prune the searchspace. You must recognize that you should not bother forming newwords that start with a word that is not in the dictionary, nor isthat word a prefix of any word in the dictionary.

Here are the valid dictionary words that can be found inside thefollowing boggle boards

4×4-board.txt ==> 4×4-board-matches.txt exactly 191words

5×5-board.txt ==> 5×5-board-matches.txt exactly 43words

10×10-board.txt ==> 10×10-board-matches.txt exactly371 words

The Assignment

Your program MUST produce exactly the same output mysolution produces on each boggle input file.

$ java Boggle dictionary.txt 4×4.txt

The only output is to be the real dictionary words (of length 3or more) you found in the grid. One word per line. No other outputof any kind. The words must be unique, no duplicates andthey must appear in sorted order ascending from top tobottom. Please see my correct output files below and makesure your solution has the same exact words as mine.

dictionary.txt    172822 words. Yourreference dictionary

INPUT FILES TO RUN YOUR SOLUTION ON

A good solution with a correctly implemented heuristicwill find all the dictionary words in even large grids (even100x100) in under a few seconds.

4×4-board.txt all real dictionary words you should find-> 4×4-board-output.txt

5×5-board.txt all real dictionary words you should find-> 5×5-board-output.txt

10×10-board.txt all real dictionary words you shouldfind -> 10×10-board-output.txt

HERE IS A SKETCH OF HOW TO DO WRITE JUST ENOUGH TO VERIFY YOU ARE CORRECTLY GENERATINGALL POSSIBLE WORDS FROM THE BOGGLE GRID.Above main declare a static long int numWordsFormed=0;In main do similar to swamp except instead of a single call to dfs // starting with EVERY letter of board, form all strings from it for every cell [r,c] in the boggle board call DFS(board, r,c, “”); println numWordsFormed;Below main write your DFS that only forms and counts wordsformed. Don’t search dictionary or do hueristics until you have verified correctness of the words/count generated.DFS( String[][] board, int r, int c, String word ){ tack the letter at [r][c] onto the end of your incoming word println( word ); // you wont want to do this for grids >= 4 ++numWordsFormed; if NORTH’s indices [r-1][c] are not out of bounds AND letter at [r-1][c] is unmarked mark the letter at r,c recurse passing in coords of N (relative to current r,c ) unmark letter at r,c if NE … if E … if SE … if S … if SW … if W … if NW …}

Edit: 2 2x2.txt c d Total unique words formed from 2x2.txt -64 ab abc abcd abdc acb acbd acd acdb adb adbc adc adcb ba bac bacd bad

2 2×2.txt c d Total unique words formed from 2×2.txt -64 ab abc abcd abdc acb acbd acd acdb adb adbc adc adcb ba bac bacd bad badc bc bca bcad bcd bcda Example output from 2×2 bda bdac bdc bdca cab cabd cad cadb cb cba cbad cbd cbda cda cdab cdb cdba da dab dabc dac dacb dba dbac dbc dbca dc dca dcab dcb dcba Show transcribed image text

Expert Answer


Answer to Game Boggle Execute Like C Java Boggle Dictionarytxt 4x4txt Boggle Input File Test Expect Q37302185 . . .

OR