update,
This commit is contained in:
BIN
ProGamerPC/ENGG1110Project.pdf
Normal file
BIN
ProGamerPC/ENGG1110Project.pdf
Normal file
Binary file not shown.
138
ProGamerPC/SampleRun1.txt
Normal file
138
ProGamerPC/SampleRun1.txt
Normal file
@@ -0,0 +1,138 @@
|
||||
Enter the number of human players [1-2]:
|
||||
2
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
5
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
7
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
5
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
3
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|X|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
7
|
||||
|
||||
# Game Board 1 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|X|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
1
|
||||
|
||||
# Game Board 1 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|X|2|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|X|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
2
|
||||
|
||||
# Game Board 1 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|X|X|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|X|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
6
|
||||
|
||||
# Game Board 1 #
|
||||
|X|8|9|
|
||||
|4|X|X|
|
||||
|X|X|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|X|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
4
|
||||
|
||||
# Game Board 1 #
|
||||
|X|8|9|
|
||||
|X|X|X|
|
||||
|X|X|3|
|
||||
# Game Board 2 #
|
||||
|X|8|9|
|
||||
|4|X|6|
|
||||
|1|2|X|
|
||||
Congratulations! Player 2 wins!
|
136
ProGamerPC/SampleRun2.txt
Normal file
136
ProGamerPC/SampleRun2.txt
Normal file
@@ -0,0 +1,136 @@
|
||||
Enter the number of human players [1-2]:
|
||||
2
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
0
|
||||
Input out of range. Please input again:
|
||||
3
|
||||
Input out of range. Please input again:
|
||||
1
|
||||
Choose the cell:
|
||||
0
|
||||
Input out of range. Please input again:
|
||||
10
|
||||
Input out of range. Please input again:
|
||||
3
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
3
|
||||
The chosen cell is occupied. Please input again:
|
||||
4
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|X|5|6|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
3
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|X|5|6|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|X|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
4
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|X|5|6|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|X|5|6|
|
||||
|1|2|X|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
5
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|X|X|6|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|X|5|6|
|
||||
|1|2|X|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
6
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|X|X|X|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|X|5|6|
|
||||
|1|2|X|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
The chosen game board is dead. Please input again:
|
||||
2
|
||||
Choose the cell:
|
||||
5
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|X|X|X|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|X|X|6|
|
||||
|1|2|X|
|
||||
# Player 2's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
6
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|X|X|X|
|
||||
|1|2|X|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|X|X|X|
|
||||
|1|2|X|
|
||||
Congratulations! Player 1 wins!
|
138
ProGamerPC/SampleRun3.txt
Normal file
138
ProGamerPC/SampleRun3.txt
Normal file
@@ -0,0 +1,138 @@
|
||||
Enter the number of human players [1-2]:
|
||||
1
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
1
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|2|3|
|
||||
# Game Board 2 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Computer's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
9
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|2|3|
|
||||
# Game Board 2 #
|
||||
|7|8|X|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
8
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|2|3|
|
||||
# Game Board 2 #
|
||||
|7|X|X|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Computer's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
2
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|X|3|
|
||||
# Game Board 2 #
|
||||
|7|X|X|
|
||||
|4|5|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
5
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|X|3|
|
||||
# Game Board 2 #
|
||||
|7|X|X|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Computer's turn #
|
||||
Choose the game board:
|
||||
1
|
||||
Choose the cell:
|
||||
3
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|X|X|
|
||||
# Game Board 2 #
|
||||
|7|X|X|
|
||||
|4|X|6|
|
||||
|1|2|3|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
4
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|X|X|
|
||||
# Game Board 2 #
|
||||
|7|X|X|
|
||||
|X|X|6|
|
||||
|1|2|3|
|
||||
# Computer's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
3
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|X|X|
|
||||
# Game Board 2 #
|
||||
|7|X|X|
|
||||
|X|X|6|
|
||||
|1|2|X|
|
||||
# Player 1's turn #
|
||||
Choose the game board:
|
||||
2
|
||||
Choose the cell:
|
||||
6
|
||||
|
||||
# Game Board 1 #
|
||||
|7|8|9|
|
||||
|4|5|6|
|
||||
|X|X|X|
|
||||
# Game Board 2 #
|
||||
|7|X|X|
|
||||
|X|X|X|
|
||||
|1|2|X|
|
||||
Computer wins!
|
7
ProGamerPC/gitUpdate.bat
Normal file
7
ProGamerPC/gitUpdate.bat
Normal file
@@ -0,0 +1,7 @@
|
||||
git status .
|
||||
|
||||
@pause
|
||||
|
||||
git add .
|
||||
git commit -m"update ProGamerPC,"
|
||||
start git push
|
153
ProGamerPC/main.c
Normal file
153
ProGamerPC/main.c
Normal file
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* ENGG1110 Problem Solving by Programming
|
||||
*
|
||||
* Course Project
|
||||
*
|
||||
* I declare that the project here submitted is original
|
||||
* except for source material explicitly acknowledged,
|
||||
* and that the same or closely related material has not been
|
||||
* previously submitted for another course.
|
||||
* I also acknowledge that I am aware of University policy and
|
||||
* regulations on honesty in academic work, and of the disciplinary
|
||||
* guidelines and procedures applicable to breaches of such
|
||||
* policy and regulations, as contained in the website.
|
||||
*
|
||||
* University Guideline on Academic Honesty:
|
||||
* https://www.cuhk.edu.hk/policy/academichonesty/
|
||||
*
|
||||
* Student Name :
|
||||
* Student ID :
|
||||
* Class/Section :
|
||||
* Date :
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
/* NO other header files are allowed */
|
||||
|
||||
/* NO global variables are allowed */
|
||||
|
||||
|
||||
|
||||
/* Initialize the specified game board.
|
||||
Please design your own representation for the game board. For example:
|
||||
- Does gameBoard[0][0] represent the top left corner or the bottom left corner of the game board?
|
||||
- Which numbers represent empty cells and crosses? */
|
||||
void initGameBoard(int gameBoard[3][3]) {
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Display the specified game board on the screen.
|
||||
You are required to exactly follow the output format stated in the project specification.
|
||||
IMPORTANT: Using other output format will result in mark deduction. */
|
||||
void printGameBoard(int gameBoard[3][3]) {
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Display the two game boards on the screen.
|
||||
Implemented for you already and no change is needed */
|
||||
void printTwoGameBoards(int gameBoard1[3][3], int gameBoard2[3][3]) {
|
||||
printf("\n");
|
||||
printf("# Game Board 1 #\n");
|
||||
printGameBoard(gameBoard1);
|
||||
printf("# Game Board 2 #\n");
|
||||
printGameBoard(gameBoard2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Return 1 if the specified game board is dead (i.e., having three-in-a-row of crosses), otherwise return 0. */
|
||||
int isGameBoardDead(int gameBoard[3][3]){
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Update the specific game board according to the user input.
|
||||
The user input may not be valid, but you can assume that it must be an integer. */
|
||||
void updateGameBoard(int gameBoard[3][3]) {
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Choose a game board and place a cross according to the user inputs.
|
||||
The user input may not be valid, but you can assume that it must be an integer. */
|
||||
void placeCrossByHumanPlayer(int gameBoard1[3][3], int gameBoard2[3][3]) {
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Return the number of crosses on the specified game board. */
|
||||
int countNumOfCrosses(int gameBoard[3][3]) {
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Determine the next move of the computer player and update the corresponding game board accordingly.
|
||||
You are required to exactly follow the strategy mentioned in the project specification.
|
||||
IMPORTANT: Using other strategies will result in mark deduction. */
|
||||
void placeCrossByComputerPlayer(int gameBoard1[3][3], int gameBoard2[3][3]) {
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The main function */
|
||||
int main()
|
||||
{
|
||||
/* Local variables */
|
||||
int gameBoard1[3][3]; // Represent Game Board 1
|
||||
int gameBoard2[3][3]; // Represent Game Board 2
|
||||
int currentPlayer; // 1: Player 1 2: Player 2
|
||||
int gameEnd; // 0: The game continues 1: The game ends
|
||||
int numOfHumanPlayers; // 1 or 2
|
||||
|
||||
/* Initialize the local variables */
|
||||
initGameBoard(gameBoard1);
|
||||
initGameBoard(gameBoard2);
|
||||
currentPlayer = 1;
|
||||
gameEnd = 0;
|
||||
printf("Enter the number of human players [1-2]:\n");
|
||||
scanf("%d", &numOfHumanPlayers); // You can assume that the user input must be valid here
|
||||
|
||||
/* Uncomment the following statements to test whether the printTwoGameBoards() and the placeCrossByHumanPlayer() functions are implemented correctly.
|
||||
You can add more if you wish.
|
||||
After testing, you can delete them or move them elsewhere. */
|
||||
//printTwoGameBoards(gameBoard1, gameBoard2);
|
||||
//printf("# Player 1's turn #\n");
|
||||
//placeCrossByHumanPlayer(gameBoard1, gameBoard2);
|
||||
//printTwoGameBoards(gameBoard1, gameBoard2);
|
||||
//printf("# Player 2's turn #\n");
|
||||
//placeCrossByHumanPlayer(gameBoard1, gameBoard2);
|
||||
//printTwoGameBoards(gameBoard1, gameBoard2);
|
||||
|
||||
/* Game start
|
||||
If there are two human players, they are Player 1 and Player 2
|
||||
If there is only one human player, he/she is Player 1 and another player is the computer
|
||||
For both cases, Player 1 moves first
|
||||
Hint: use a while loop */
|
||||
|
||||
// TODO: Complete this part
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user