The Game of Boggle

 


The Game of Boggle: The object of game Boggle is to find as many words as possible in a k by k grid of letters. Words may be formed from any sequence of 3 or more adjacent letters in the grid. The letters may be joined together horizontally or vertically (but not diagonally as in the standard Boggle rules). No position in the grid may be used more than once within any one word. You may not wrap around the grid.  The first line of the input is the integer k, followed by k lines with k characters per line. For instance, a sample grid might look like:

4
scvs
alta
nfdt
gtam

This grid yields all the following words: dam mad sat tam tat salt plus perhaps some other words. For more general information on Boggle, check out the Wikipedia entry http://en.wikipedia.org/wiki/Boggle

Official Dictionary: The official dictionary for this assignment is 5desk.txt

 

What your Program Should Do: Your program should be written in standard Java. Your program should read the dictionary from the file 5desk.txt. To get you started, BoggleBoard.java is a program that reads in the board and prints it out. Your program should read the Boggle board in the format specified above (the first line specifies the integer k, and the following k lines give the board) from a file named board. Your program should print all the words that it finds in the grid in alphabetical order to a file named foundwords. Your program should not print out duplicate words. Your dictionary must be implemented as a Patricia Tree. You use the code in the text as a starting point, or Kirk’s pseudo-code, or start from scratch on your own. You may not copy code Patricia code from any other source.

 

You are encouraged to optimize your program so that it runs as quickly as possible.

 

Test Inputs: Run your input on the following board to test the correctness of your algorithm.:.We may also test your code on an input we generate.

 

Experimentation: The following table gives the frequency of letter occurrences English words.

 

    

# of Occurrences

e

42689

11.74%

i

31450

8.65%

s

29639

8.15%

a

28965

7.97%

r

27045

7.44%

n

26975

7.42%

t

24599

6.76%

o

21588

5.94%

l

19471

5.35%

c

15002

4.13%

d

13849

3.81%

u

11715

3.22%

g

10339

2.84%

p

10063

2.77%

m

9803

2.70%

h

7808

2.15%

b

7368

2.03%

y

6005

1.65%

f

4926

1.35%

v

3971

1.09%

k

3209

0.88%

w

3073

0.85%

z

1631

0.45%

x

1053

0.29%

j

727

0.20%

q

682

0.19%

MakeBoggleBoard.java  is a program to generate Boggle boards, of a specified size, such that each letter is generated independently with the above distribution (To be supplied latter). Calculate the worst case running time of your program (say if every possible string of letters was a valid word) as a function of k. Hypothesize what you would expect the running time to be as a function of k if the board is generated by the supplied program. Test your hypothesis by running your program on many boards.

 

Write-up: Write a 2-6 page report describing

 

What your should turn in: Your program source, your executable, your report, the output of your program on the sample input, and you assignment information sheet.