CMPS290e: Calibration Programming Assignment

Objective

The objective of this assignment is for you to demonstrate your programming ability using an object-oriented programming language of your choice. If the langage is not from the list: Java, C++, or C#, please check with one of the instructors for approval before proceeding.

The problem

For this assignment you are to write a program to compute and print the number of liberties for stones on a Go board, and identify which stones are connected into groups.

Go is played on a square grid typically with 9, 13, or 19 vertical and horizontal lines. There are two players and they take turns placing black or white stones (one color for each player) on the intersections of the lines.

A liberty is an unoccupied intersection, adjacent to a stone. Adjacent means connected by a line (diagonals are not adjacent). For example, a single stone placed away from any edge has four liberties (one north, one south, one east, and one west).

A group of stones of the same color is connected if you can move from any stone in the group to any other stone passing only through intersections occupied by stones of the same color. For example, the following board has three groups (two black groups and one white group).

......W..
..BB..W..
...BWWW..
....B....
....B....
.........
.........
.........
.........
Liberties are shared by stones in a group. For example, the upper left black group in the previous example has 6 liberties marked with L in the following:
..LL..W..
.LBBL.W..
..LBWWW..
...LB....
....B....
.........
.........
.........
.........
The white group has 8 liberties.

That is all you need to know about Go for this assignment. You can learn more at any of the many Go sites on the web. This looks like a reasonable place to start: http://www.well.com/user/mmcadams/gointro.html.

Requirements

Your program must adhere precisely to the input and output specifications stated here.

Input: Your program should read its input from standard input. The first line of input will be a single integer, either 9, 13, or 19, specifying the size of the board. If S is the size of the board, then the next S lines will each contain a sequence of S characters from the set {".", "B", "W"}. That's a dot for empty, a B for a black stone, or a W for a white stone.

Output:

This page maintained by Charlie McDowell. Email regarding this site.