C++

Completed Posted Mar 3, 2004 Paid on delivery
Completed Paid on delivery

The Objective The objective of this assignment is to give you practice with project and function design. It will also give you an opportunity to work with a two-dimensional array and passing that array to functions for manipulation. The Background

The game Connect 4 is a popular game sold in both full-size and travel sizes. The board is vertical and forms a grid that is 6 rows high by 7 columns wide. This game is played by two players, each with their own color of checkers (either red or black). Checkers are dropped into the columns by each of the players in turn. The object of the game is to be the first player to get 4 of your checkers in a row, either horizontally, vertically, or diagonally.

Play begins by one player choosing a column in which to drop a checker. Since this is the first play, the checker will fall to the bottom of that column. The other player then gets to drop one of his checkers into the column of his choice. If player #2, your opponent, chooses to drop his checker in a different column than you did, it will fall to the bottom of that column. If he chooses the same column as you did then his checker will land just above yours. So the rule of placement is that the checker will fall down the column as far as it can.

If you would like to practice playing the game so that you understand it, I have found a version of it on the web that will allow you to play against the computer.

## Deliverables

The Task

Design and code a project that will allow you to play Connect 4 against the computer.

The Specifications

* The board must be implemented as a two-dimensional array of chars

* You may use an array that has 6 rows and 7 columns, or one that has 7 rows and 8 columns (for easier conversion of the user's choice to the array index).

* **You may NOT use an array that is larger than 7 X 8**, since a large part of this project is intended to teach you to work with 2-d arrays by checking edge conditions without looking at memory locations that are outside of the array bounds.

* You must use the character O to indicate a human player's checker and the character X to indicate a computer's checker.

* The human player takes his turn first.

* The computer will **NOT** play intelligently. It **must** place its pieces by getting a randomly selected column number. If that column is already full, then another random column must be chosen until a checker can be placed.

* Since it is almost impossible to grade a program that makes random, unforeseeable choices, your program must run in two different modes, test and play.

* Test mode must be used for grading and can be very helpful to you for debugging purposes. Test mode simply means that you will seed the random number generator by asking the user to enter a positive integer to be used as the seed. Remember that if you always enter the same seed, the same set of random numbers will be produced every time you play. This means that if you always use the same seed, the computer will always place its pieces in the same places in the same order.

* Play mode can then be used to actually play the game. For play mode you will seed the random number generator by using a call to the time() function. This will mean that you'll have no idea where the computer will place its next piece, just like a real game.

* Hint: This is not a big deal. It only involves how you seed the random number generator. This is only done once before play actually begins.

* After determining the mode, you must display an empty board and prompt the human player for his choice of column. You will then place his piece and display the board again. The computer will then automatically take its turn, reporting the column it chose, place its piece, redisplay the board and ask for the human's choice. This process will continue until there is a winner. (See sample output below)

* After each turn, whether human or computer, your program must check the board to see if there is a winner. To win one player must have 4 of his pieces in a row, either vertically, horizontally, or diagonally. There are two ways to win diagonally. Diagonals can go from lower left to upper right or from upper left to lower right. If there is a winner, the game is over and the winner should be announced.

* If the board is filled and there is no winner, then the program should produce a message that there was a tie and the program should end.

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.

2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request.

3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).

## Platform

This is the sample run , that was generated by running the program on linux2. In test mode, your projects should match the output produced by my program in the test mode examples.

Although your output need not be identical to that in the output file, all information (including a greeting and instructions that are not shown in the output) must be present. In TEST mode, using the same seed as I did, and entering the column choices in the same order should produce the same game with the same results for your project.

Please be aware that this may **NOT** be a complete test of the program.

C Programming Engineering MySQL PHP Software Architecture Software Testing

Project ID: #3119943

About the project

6 proposals Remote project Active Mar 3, 2004

Awarded to:

bogdan123vw

See private message.

$23.8 USD in 1 day
(48 Reviews)
3.8

6 freelancers are bidding on average $23 for this job

mihaiscortaru

See private message.

$22.6 USD in 1 day
(160 Reviews)
6.0
senzaciosnegyes

See private message.

$25.5 USD in 1 day
(104 Reviews)
4.9
lmxvw

See private message.

$21.25 USD in 1 day
(126 Reviews)
4.7
cearnyold

See private message.

$17 USD in 1 day
(12 Reviews)
3.5
patrica

See private message.

$25.5 USD in 1 day
(19 Reviews)
3.2