CMSC132 Summer 2018

Project: Recursion Excursion

Due Date: July 11, 2018 11:59PM
Assignment Type: Closed (See Policy)

Overview Image Blocks (Part A)

A binary digital image is a rectangular grid of black and white pixels. The image shown in Figure 1 consists of 17*9 pixels. In this project, you write a program to count the connected blocks in a binary digital image. For example: There are three connected blocks in Figure 2a, six connected blocks in Figure 2b, 14 connected blocks in Figure 2c, and one connected block in Figure 2d. If we count white blocks, there are two connected blocks in Figure 1.

 

The “Picture” class in the utils package can read and show digital image files. You can also get the height, width of the image, and the color of each pixel on the image. The following code opens a image file, displays it, returns the height and width of the image, and the color of a pixel at grid position x,y.

Picture pic = new Picture(fileName);
pic.show();
height = pic.height();
width = pic.width();
Color t = pic.get(x, y);

In order to find a connected block, you find a black pixel, then you recursively visit all neighbors of the pixel to check if any neighbor is a black pixel too. Then you move to the neighbor, and repeat until no more “black pixel” neighbors. As shown in Figure 3, there are 8 neighbors a pixel.

 

 

 

Overview Boggle (Part B)

In the classic board game "Boggle" players compete to find as many words as they can before time runs out. The larger the word, the more points they earn and the player with the most points wins. The game consists of a grid where each tile is a random letter. Words are formed by starting with one letter and moving to adjacent letters in the grid. You can move horizontally, vertically, and diagonally, but you can't use the same tile twice in one word. For example, figure 4a shows a valid Boggle word "spa" while in figure 4b, "spas" is an invalid word because you cannot use the same letter "s" twice.

 

The "LetterGrid" class in the utils package stores the grid of letters that represents the Boggle board. You can get information regarding the number of columns, rows, and letter at each coordinate of the grid.

Your job is to figure out if a word is valid by recursively traversing the Boggle board.

Objectives

This project will allow you practice recursion and testing.

Grading

Clarifications

Any clarifications or corrections associated with this project will be available at Project Clarifications.

Code Distribution

The project's code distribution is available by checking out the project named ImageBlocks. The code distribution provides you with the following:

Specifications

Requirements