Let's try TEST mode and make sure we can win.
We'll attempt a vertical connect 4.
linux2[72] % a.out
Let's play Four-In-A-Row !
Put your greeting and instructions here
This game will run in either test or play mode.
- Test mode is used while you are writing and debugging
your code and for grading (Uses a seed input by the player)
- Play mode is used after you have finished your project
and really want to play the game (Uses a random seed)
Which mode would you like to use:
1 - Test
2 - Play
Enter your choice: 1
Please enter a positive integer to be used as the
seed for the random number generator : 7
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | O | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | O | | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | O | | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 4.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | O | | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
| | | | X | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | O | | |
|---|---|---|---|---|---|---|
| | | | | O | | |
|---|---|---|---|---|---|---|
| | | | | O | X | |
|---|---|---|---|---|---|---|
| | | | X | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
YOU WIN !!!
Okay, let's see if we can let the computer win one. This requires
patience !
linux2[73] % a.out
Let's play Connect 4 !
Put your greeting and instructions here
This game will run in either test or play mode.
- Test mode is used while you are writing and debugging
your code and for grading (Uses a seed input by the player)
- Play mode is used after you have finished your project
and really want to play the game (Uses a random seed)
Which mode would you like to use:
1 - Test
2 - Play
Enter your choice: 1
Please enter a positive integer to be used as the
seed for the random number generator : 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 5.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | X | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | O | O | X | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | O | O | X | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 2
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | O | O | O | X | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 1.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | O | | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 1.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | | O | | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 7.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | | | |
|---|---|---|---|---|---|---|
| X | | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 1.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | | | O | | | |
|---|---|---|---|---|---|---|
| X | | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 2
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | | | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 2.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | X | | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | | X | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 2
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | | X | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 2.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | | X | |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 7
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | O | | X | O |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | X | |
|---|---|---|---|---|---|---|
| X | O | O | O | | X | O |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 7
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | X | O |
|---|---|---|---|---|---|---|
| X | O | O | O | | X | O |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 1.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| X | O | | | | | |
|---|---|---|---|---|---|---|
| X | X | O | O | | X | O |
|---|---|---|---|---|---|---|
| X | O | O | O | | X | O |
|---|---|---|---|---|---|---|
| X | O | O | O | X | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
I WON !!!
Better luck next time
Now let's try a horizontal win.
linux2[74] % a.out
Let's play Connect 4 !
Put your greeting and instructions here
This game will run in either test or play mode.
- Test mode is used while you are writing and debugging
your code and for grading (Uses a seed input by the player)
- Play mode is used after you have finished your project
and really want to play the game (Uses a random seed)
Which mode would you like to use:
1 - Test
2 - Play
Enter your choice: 1
Please enter a positive integer to be used as the
seed for the random number generator : 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 2.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | O | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | O | O | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 7.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | O | O | | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | O | O | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 4.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | | | |
|---|---|---|---|---|---|---|
| | X | O | O | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 6
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | | | |
|---|---|---|---|---|---|---|
| | X | O | O | O | O | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
YOU WIN !!!
Let's try an upper-left to lower-right diagonal win.
linux2[76] % a.out
Let's play Connect 4 !
Put your greeting and instructions here
This game will run in either test or play mode.
- Test mode is used while you are writing and debugging
your code and for grading (Uses a seed input by the player)
- Play mode is used after you have finished your project
and really want to play the game (Uses a random seed)
Which mode would you like to use:
1 - Test
2 - Play
Enter your choice: 1
Please enter a positive integer to be used as the
seed for the random number generator : 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 2
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 2.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | O | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 7.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | O | | | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | O | | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 4.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | | | | |
|---|---|---|---|---|---|---|
| | O | O | X | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | | O | | | |
|---|---|---|---|---|---|---|
| | O | O | X | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 3.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | X | X | O | | | |
|---|---|---|---|---|---|---|
| | O | O | X | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | O | | | | |
|---|---|---|---|---|---|---|
| | X | X | O | | | |
|---|---|---|---|---|---|---|
| | O | O | X | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 1.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | O | | | | |
|---|---|---|---|---|---|---|
| | X | X | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | X | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 2
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | O | O | | | | |
|---|---|---|---|---|---|---|
| | X | X | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | X | O | | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | O | O | | | | |
|---|---|---|---|---|---|---|
| | X | X | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | X | O | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 2
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | O | | | | | |
|---|---|---|---|---|---|---|
| | O | O | | | | |
|---|---|---|---|---|---|---|
| | X | X | O | | | |
|---|---|---|---|---|---|---|
| X | O | O | X | O | X | X |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
YOU WIN !!!
Okay, now a lower-left to upper-right diagonal
linux2[77] % a.out
Let's play Connect 4 !
Put your greeting and instructions here
This game will run in either test or play mode.
- Test mode is used while you are writing and debugging
your code and for grading (Uses a seed input by the player)
- Play mode is used after you have finished your project
and really want to play the game (Uses a random seed)
Which mode would you like to use:
1 - Test
2 - Play
Enter your choice: 1
Please enter a positive integer to be used as the
seed for the random number generator : 7
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 3
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | O | O | | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 6.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | X | |
|---|---|---|---|---|---|---|
| | | O | O | | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | | X | |
|---|---|---|---|---|---|---|
| | | O | O | | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 4.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | | | |
|---|---|---|---|---|---|---|
| | | | O | | X | |
|---|---|---|---|---|---|---|
| | | O | O | | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | | | |
|---|---|---|---|---|---|---|
| | | | O | | X | |
|---|---|---|---|---|---|---|
| | | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 2.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | | | |
|---|---|---|---|---|---|---|
| | | | O | | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | | | |
|---|---|---|---|---|---|---|
| | | | O | O | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 2.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | | | |
|---|---|---|---|---|---|---|
| | X | | O | O | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | O | | |
|---|---|---|---|---|---|---|
| | X | | O | O | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 5.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | X | | |
|---|---|---|---|---|---|---|
| | | | X | O | | |
|---|---|---|---|---|---|---|
| | X | | O | O | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 6
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | X | | |
|---|---|---|---|---|---|---|
| | | | X | O | O | |
|---|---|---|---|---|---|---|
| | X | | O | O | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 4.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | X | | |
|---|---|---|---|---|---|---|
| | | | X | O | O | |
|---|---|---|---|---|---|---|
| | X | | O | O | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 6
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | X | X | O | |
|---|---|---|---|---|---|---|
| | | | X | O | O | |
|---|---|---|---|---|---|---|
| | X | | O | O | X | |
|---|---|---|---|---|---|---|
| | X | O | O | O | X | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
YOU WIN !!!
linux2[78] %
Okay, we've won all 4 possible ways. The computer has also managed to
win, but all of this was in TEST mode. Let's see if we can play a game in
PLAY mode.
linux2[79] % a.out
Let's play Connect 4 !
Put your greeting and instructions here
This game will run in either test or play mode.
- Test mode is used while you are writing and debugging
your code and for grading (Uses a seed input by the player)
- Play mode is used after you have finished your project
and really want to play the game (Uses a random seed)
Which mode would you like to use:
1 - Test
2 - Play
Enter your choice: 2
A random seed was set
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 4
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | O | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 3.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | X | O | | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 5
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | X | O | O | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 5.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | X | | |
|---|---|---|---|---|---|---|
| | | X | O | O | | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 6
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | X | | |
|---|---|---|---|---|---|---|
| | | X | O | O | O | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's my turn and I choose column 1.
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | X | | |
|---|---|---|---|---|---|---|
| X | | X | O | O | O | |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
It's your turn.
Play your piece in which column: 7
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | | | |
|---|---|---|---|---|---|---|
| | | | | X | | |
|---|---|---|---|---|---|---|
| X | | X | O | O | O | O |
|---|---|---|---|---|---|---|
1 2 3 4 5 6 7
YOU WIN !!!
linux2[80] %
Disclaimer: THIS IS NOT A COMPLETE TEST OF THE PROGRAM. There was at
least one important test left out. What is it ? You'll need to do more
testing of your program.