Connect Four ( Due 29 Jul 2013 )

Connect Four is a game played between two players. Each player chooses a color - say red or black. The players then take turns in dropping plastic counters of their chosen color into a vertical grid that has 7 columns and 6 rows. The object of the game is to be the first person to have 4 contiguous counters of their chosen color in the same row, or same column, or along the same diagonal.

Your input will be in a file called connect.txt. The first line in that file will be two integer numbers m and n. The number m represents the number of rows and the number n represents the number of columns. This will be followed by m lines of data. Each line of data will have n characters - R, B, and X. The character R represents a red counter, B represents a black counter, and X represents an empty space in the grid.

Your program will open the input file and read the first line of data. It will then create a 2-D array having the number of rows and columns as specified. It will then populate the array with data from the input file.

You will develop an algorithm to determine if there are 4 contiguous R or B characters in the array. There will be only 3 possible outputs:

Assume that there are no errors in the data file. However, in the event that there are 4 contiguous counters for both colors, then print Tie.

We will be looking at good documentation, descriptive variable names, and adherence to the coding convention mentioned below. Your file will have the following header:



  Student Name:

  Student UT EID:

  Course Name: CS 312

  Unique Number: 

  Date Created:

  Date Last Modified:


You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code. For example:

Do this:
if ( x > 5 )
  a = b + c;

Not this:
if ( x > 5 ) {
  a = b + c;

Use the turnin program to submit your .java file. The proctor should receive your work by 11 PM on Monday, 29 Jul 2013. There will be substantial penalties if you do not adhere to the guidelines.