Question
someone please help me with this boggle game code. here are the details. comment if you need more clarification Your program MUST produce exactly the
someone please help me with this boggle game code. here are the details. comment if you need more clarification
Your program MUST produce exactly the same output my solution produces on each boggle input file.
$ java Boggle dictionary.txt 4x4.txt
The only output is to be the real dictionary words (of length 3 or more) you found in the grid. One word per line. No other output of any kind. The words must be unique, no duplicates and they must appear in sorted order ascending from top to bottom. Please see my correct output files below and make sure your solution has the same exact words as mine.
dictionary.txt 172822 words. Your reference dictionary
INPUT FILES TO RUN YOUR SOLUTION ON
A good solution with a correctly implemented heuristic will find all the dictionary words in even large grids (even 100x100) in under a few seconds.
4x4-board.txt all real dictionary words you should find -> 4x4-board-output.txt
5x5-board.txt all real dictionary words you should find -> 5x5-board-output.txt
10x10-board.txt all real dictionary words you should find -> 10x10-board-output.txt
this is how I will test it and will expect you use args[0] as the dictionary 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 recursion and backtracking. Backtracking is a technique whereby an algorithm recognizes it is impossible or unnecessary to search any deeper into the search space from a given point. An example of this is finding your way through a maze. When you hit a dead end you retreat from that point and never take the same path to that point again. A fast and efficient solution to Boggle requires a heuristic that helps you recognize a dead end and save vast amounts of wasted words formed and wasted searches (and thus vast amounts of time).
Boggle is a board game that uses 16 dice arranged in a 4 x 4 grid. There is also a 5x5 version. Each die has 6 faces with a letter of the alphabet on it. Occasionally the string "Qu" will appear on a dice face.
Here is a development strategy you should follow which verifies the string generating component algorithm first before searching the dictionary, deploying a heuristic or building a GUI.
HERE IS A SKETCH OF HOW TO DO WRITE JUST ENOUGH TO VERIFY YOU ARE CORRECTLY GENERATING ALL 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 ... }
here just some words from the dictionary file
dictionary.txt
reinflates misorders discontinuations gastness grousers sandshoes keps inspissations bawd idolatrous snuggle disastrous improvidently hemicycle lighted preformatting groundworks forthrights
an example of a board
4x4.txt
4 qu e a i n e r e t w s t o r k y
4x4.txt solution
aerie aeries aeriest air airest airs airt airts are ares ars arse art arts artsy arty ear ears eerie eeriest enter entera enters era ere ers erst ester ire ires kyte kytes near nearest nears nee nerts nest nester net network networks new news newsy newt ors ort owe owes own owner owners owse owsen queen queer queerest queers queries quest quester ree rees reest rei renest renew renews rent rente rentes request res resee reseen resent reset resew resewn rest ret retro rets rework reworks ria rot rote rotes row rowen rower rowers rows sea sear see seen seer sei sen sene sent sequent ser sera serai sere serene set sew sewn sky sri stere street strew strewn stria striae sty swear sweer swot tea tear teariest tears tee teen ten terai terse test tester testy tew tews tor tors torse torsk tow tower toweriest towers town townee townees tows tree treen trees tret trews tries trow trows tsk twee tween two wear wearies weariest wears wee ween weer wen went were wert west wester wet work works worse worsen worser worset worst wort wot wren wrest wries wriest wrote
I need it for all of the boards.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started