transputer.gif (9866 bytes)
Brock University
Department of Computer Science

COSC 3F00: Software Engineering

Fall 2017 Instructor: Vlad Wojcik mail.gif (1189 bytes)

Assignment # 2: Friday, 10 Nov 2017, 4 PM.

darkDot.gif (501 bytes)ASSIGNMENT OBJECTIVE:c4board

The goal of this assignment is to make you familiar with concurrent programming in a language of your choice: C++ or Ada, while solving a simple gaming problem.

darkDot.gif (501 bytes)THE PROBLEM:

As children, probably all of us have played a game of Connect Four (also known as Plot Four, Four-in-Line, etc.). It is a simple game, played on a 7x7 (sometimes 8x8) grid, depicted beside.

The game starts with an empty board. Two players take turns and drop tokens (shown here brown and blue) on the columns in the board, labelled A through H. The tokens fall down and settle as low as possible (in the row 1 if a given column is empty, or else just above the highest token in a given column).

The first player who gets four of his tokens aligned (horizontally, vertically, or diagonally) wins.

We will play a generalized (cylindrical) game of Connect Four, played on a 8x8 board rolled into a vertical cylinder, thus making columns A and H adjacent.

To add to your challenge, in the spirit of Tetris we will assume that when row 1 is full it disappears; that is, all tokens above it (if any) fall one row down. For example: Adding a token to the column H (see arrow) would make the entire row 1 disappear.

There is only one exception to this rule: If completion of row 1 results in four identical tokens in a row, then the game is over and one of the players wins.

darkDot.gif (501 bytes)THE SOFTWARE:

Write an Ada or C++ program that would play the generalized game of Connect Four. This program should consist of two parts: the main program/thread and the game playing task/thread. The main program/thread would provide some simple (perhaps ASCII? -- the design decision is yours) interface to the user, while the other task/thread would "think" about the strategy, regardless whether it is its turn to move or not. This approach may enhance the interactivity of the game.

Upon launching the game, the main program/thread would ask the user who is to go first. Having gotten this answer, the main program/thread should launch a suitable game playing task/thread.

The main program/thread should then be responsible for:

  1. The dialogue with the human player;
  2. The dialogue with the game playing task/thread;
  3. Displaying simple (perhaps ASCII?) game interface, showing the state of the game;
  4. Tallying the alignments for both players as game progresses;
  5. Announcing the winner;
  6. Terminating the game when needed.

The game playing task/thread should be responsible for:

  1. Accepting the moves of a human player (communicated to it by the main program/thread);
  2. Informing the main program/thread about its moves;
  3. Playing the Connect Four game to the best of its ability;
  4. Being as responsive as possible: "thinking" about its likely next move while attentively waiting for the next human move.

You may be asked by your prof or marking TA to demonstrate that your program works.


For convenience, students may code and compile their program assignments using a variety of platforms and compilers that are not available in the Computer Science Labs. During assignment marking, if assignments have been submitted in any of these miscellaneous formats, the marker will not be able to compile and test run the assignment in the Lab and therefore, will not be able to provide a mark. It is the responsibility of each student to compile and test run their assignment program on the software provided either in Labs D205 or J310. The following software is available in the lab: Visual Studio 2015, AdaCore GPS 2016, Redhat Linux 6 or Unix on Sandcastle.

Checklist of items before submission:

  1. Include a brief one page outline of program design.
  2. Compile and test run assignment program in Lab.
  3. Make sure all files are included in the submission folder.
  4. Include any special instructions for compiling and running if using Unix platform.
  5. Include a copy of assignment program output for markers use.

darkDot.gif (501 bytes)SUBMISSION FORMAT:

Both hardcopy (paper) and electronic submission is required.

Hardcopy submission: Your submission envelope with the standard Cover Page should contain all relevant printouts and supporting documentation, demonstrating your design and flawless behaviour of your program. The envelope should be dropped in the submission box on or before deadline date / time.

Electronic submission: Please create a directory on Sandcastle and place within it all the files (and only the files) to be submitted. To submit issue the command submit4f00, which is interactive in its nature. Obviously, you are allowed to submit your assignment only once. Should you encounter difficulties, please report them to your TA.

Similarly, the electronic submission should be performed on or before deadline date / time.

darkDot.gif (501 bytes)PENALTIES:

Possible lateness in assignment submission is counted in days, each period of a day ending at 4 PM. The penalty for late submission of assignments is 25% up to three days (or a part of a day). After that period the penalty is 100%.

While honest cooperation between students is considered appropriate, the Department considers plagiarism a serious offense. For clarification on these issues you are directed to the statement of Departmental Policies and Procedures.

cameo.gif (1740 bytes)Instructor: Vlad Wojcikmail.gif (1189 bytes)
Revised: 16 October, 2017 10:36 PM
Copyright 2017 Vlad Wojcik