ESTR1002, 2024-2025 Course ProjectPage 1 of 13ESTR1002 Problem Solving by Programming 2024 – 2025 Term 1 Course Project – Chinese CheckerESTR1002, 2024-2025 Course ProjectPage 2 of 13Figure 1: the game board of ageneral Chinese checker. Source:IntroductionChinese checker is a turn-based board game played by two,three, four or even six people. The rules are simple. Each playercorner—usingsingle-step moves or multi-jump movesover some other pieces.You SHOULD first learn how to play it:
https://www.coolmathgames.com/0-chinesecheckersThis project is a simplified version of the game. We consideronly two players seated at the opposing corners of an 8x8squareboard; see Figure 2 below. Each player has six chess
pieces of his/her own. In general, the game is won by being thefirst to transfer all of one's pieces from his/her camp into theopponent’s camp. In each turn, a player canmoveone of his/her chess pieces by either
(i) moving one single step to an adjacent empty cell or (ii) jumping through empty cellson the game board over some other pieces successively; we will show you someexampleslater in this spec.
1.1 Project overview In this course project, you need to submit (see Section 6 in this spec. for details)
1) [basic] a C program to provide an interactive gameplay for two human players.
- 2) [basic] an embedded computer player to replace one of the two human players.
- 3) [bonus] our great tournament: compete with the computer player of your classmates.
- Game Rule
2.1 Game board The board consists of an 8x8 grid of 64 cells, see Figure 2.
- There are two players in this game.
- Each player has six pieces, e.g., blue or red.
- Each player's camp consists of six cells on top-left andbottom-right corners of the game board; see Figure 2.
- The game starts with each player's camp filled by piecesof his/her own color.We store the game board using a one-dimensional integer array of length 89. The location of each cell in the board is represented using an integer
The cell just under 11 is 21. See the cell coordinates below.Figure 2. The initial game
board of “Chinese chec this is the name of the ker” game. ---ESTR1002, 2024-2025 Course Project
Page 3 of 13
Figure 3. Encoding of the piece locations.
Since we use an array of length 89, except for the 64 positions on the board, other
ositions are unused, where chess pieces should not be placed. Also, beware of the “arrayout of bound error” in this project.The game always starts with the blue player, whose camp is located at the upper-left corner.
2.2 Represent the cells of the board
- Empty cells: 0. For example, if the value of board [67] is zero, this means thatositions with blue chess piece: 1. For example, if the value of board [45] is onehis means that there’s a blue chess piece at 4th row and 5th column.
- Positions with red chess piece: 2. For example, if the value of board [45] is two,this means that there’s a red chess piece at 4th row and 5th column.
- All other positions outside the game board: -1.
2.3 Play sequence
- The player of the top-left corner always moves first.
- Pieces may move only in eight possible directions (orthogonally and diagonally).
- In each turn, a player can have the following possible moves:
o a single-step move to an adjacent empty cell; see possible moves #1a and #1b inFigure 4. Example possible moves for example horizontal and diagonal moves,be the player’s own piece or opponent’s piece); see possible moves #2a and #2bin Figure 4. Example possible moves for example vertical and diagonal jumps,
respectively;o also, we can have a long distance jump to an empty cell with exactly one singlepiece in the middle between the lifting and landing locations in that jump; seepossible move #3in Figure. 4; ando a multi-jump move with more than one jumps successively through some emptycells, while having only one single piece in the middlebetween the landing andligure 4. Example possible moves, starting from the current game board shown on the top left corner. 2.4 Game End condition: Win or Draw There are only two possible “end game” conditions, i.e., one of the two players wins; orthe game is a draw. The detailed conditions are specified as follows:
(1) WIN: After a move has been made, a player A wins the game if his/her opponent’scamp is filled with pieces, among which at least one belongs to A; and(2) DRAW: after each player has moved 100 steps, if there is no winner, then the gameends with adraw.Programming GuidelinesWe describe some key functions as guidelines for you. Please note that we do not use theonline judge for the project, but still, you should follow some formats for consistentgrading.ESTR1002, 2024-2025 Course Project
age 5 of 13
31 Program Design of “Chinese Checker”
Figure 6. The program flow.
Note: you may create additional functions (e.g., to check if a chess piece can jump overanother one) in your program to make your program more modular and easier toebug.This is also for you to learn and try the divide-and-conquer concept we discussed in class.
.2 Requirements
hough the online judge system is not provided, you have the following set ofequirements for consistent and fair grading.
Your program must read inputs from the keyboard, so that we can test your codeconsistently, i.e., we will input a sequence of four-digit integers and see if yourprogram can generate the expected results.
- Note that we will try some invalid moves and see if your program can find them.
- Your program must print the results to the terminal / command prompt.
- During each round of the game, your program must report:
o the current status of the game board using the above representation;o print the next player; ando if a player places a chess piece on an illegal position, print out the notification,and ask the user to input again.
At the end of the game, you must report
o who is the winner, or a draw.
3.3 Function #1: Initialize the game board
In this function, you simply initialize the board array according to the description inSections 2.1. ESTR1002, 2024-2025 Course ProjectPage 6 of 13
3.4 Function #2: Display user interface First, you should write a function to draw the user interface, i.e., to print the game board‘#’ to represent blue,‘O’ to represent red, and
‘ . ’ to represent an empty cell.Figure 7 below shows a sample screenshot of the game board presented Figure 2.Figure 7. An example of printing the game board. 3.5 Function #3: Read a move from the user Second, you need to write a function to ask and receive the next move from the user. Weuse a four-digit integer to represent a move, where the first and last two digits representthe starting (lifting) location and ending (landing) location, respectively. For example,2161 means moving the piece on 2nd row 1st column to 6th row 1st column, regardless ofthe intermediate locations. See Figure 8: We use “2161”to represent the move “from (2,1)
to (6,1) after two jumps”.
Fgure 8. We use "2161" to represent the move “from (2,1) to (6,1)”.
3.6 Function #4: Check if a move is valid
The inputs by a player may not always be correct, e.g., the provided starting location maynot contain a piece, the piece cannot be moved/jumped to the target location, or the inputis not a four-digit integer at all! This is the more challenging component in the basicpartof this project. Hint: use recursion. To check whether a move is valid, your programshould check if(1) each input is a four-digit integer, otherwise, print “Invalid input format, please inputagain:”;(2) each input location (both starting and ending) is within the game board range “[1,1]to [8,8]”, otherwise, print “Input out of the game board, please input again:”;(3) thereexists a chess piece from the current player at the provided starting location,otherwise, print “Invalid starting location, please input again:”;(4) there should not be anychess piece at the ending location, otherwise, print “Invalidending location, please input again:”; 代寫ESTR1002 Problem Solving by Programming andESTR1002, 2024-2025 Course ProjectPage 7 of 13(5) the move from the starting location to ending location should be valid, i.e.,followingthe rules specified in Section 2.3 Play sequence, otherwise, print “The move violateshe game rule, please input again:”.
3.7 Function #5: Check if the game is over
Every time a player finishes a move, your program should call a function, which checks ifthe game ends or continues (based on the current player), according to the rules specifiedin Section 2.3 “Game End” condition: Win or Draw. If the game is over, print the winner.
lso, if both players have finished the maximum allowed number of moves and there are
no winners, the function should return a value to indicate a “draw” rather than “win” or“continue”.
3.8 Test your “human v.s. human” gameplay
We have provided to you two sample test files on the course webpage (blackboard) for
you to download and test “human vs. human” gameplay.Note that since your gameplay should support both “human v.s. human” mode and“human v.s. computer” mode, at the very beginning of the game, your program should askthe user to choose between the two modes by inputting an integer. Here, “1”means“human v.s. human” and “2” should mean “human v.s. computer”.A typical case is like this:775522232422……ESTR1002, 2024-2025 Course ProjectPage 8 of 13Computer PlayerAfter finishing the “human vs. human” part, you will come to the most challengingandexciting part of the project, where we replace the function in Section 3.5 Function #3:Read a move from the user by a computer player function.To implement a computer player,you mainly need to finish one function. The prototypeof the function is defined below:
nt ai_player ( int player , const int * board ); This function needs the following inputs:
- int player: the chess piece that the current player uses: blue is 1 and red is 2.
- const int *board: this is a one-dimensional array (const means constant, i.e., yourfunction should not modify the contents of the input array) that represents thecurrent cellconditions in the game board, same at what is defined in Section 2.2:
o Empty cells: 0. For example, if board [67] = 0, this means that there’s no chesspiece on the cell at 6th row and 7th column, you may put a chess piece there.o Positions with blue chess piece: 1. For example, if board [45] = 1, this means thatthere’s a blue chess piece at 4th row and 5th column.o Positions with red chess piece: 2. For example, if board [45] = 2, this means thatthere’s a red chess piece at 4th row an5th column.o Other positions not on the board: -1.
- The return value (int): this function returns a four-digit integer that represents a
move; see Section “3.5 Function #3: Read a move from the user” for its meaning.
4.1 “Human v.s. computer” mode Since you already have a function from Sec. 3.5 to scan a user input from the human, youcan simply replace it by the ai_player function you just implemented in your mainprogram to support the “human v.s. computer” mode, without implementing other gamelogics twice. At the beginning of your program, if the user chooses mode “2”, yourprogram should enter the “human v.s. computer” mode. You may further ask the user tochoose between “computer plays first” of “human plays first”, or, you may always let thecomputer to play first/second.4.2 [Bonus] The great tournament!!! This bonus part is an extra!!! After evaluating the “human v.s. human” and “human v.scomputer” parts of your program, we will evaluate how smart your computer player isby creating a tournament for the computer players of all the students in the class tocompete against one another.Below is the game rule:For each student’s computer player, it will play two games against the computerplayer of each of theother classmates.
- In each of these two games (between the same pair of students), each computerplayer takes turns to use the blue chess piece and to start the game first.ESTR1002, 2024-2025 Course Projectage 9 of 1You score 2 points for each game you win and 1 point for each draw; you got zeropoints if you lose or your program does not follow any requirements we define inthis project specification.4.3 Requirements of the computer player (for both “human v.s. computer”and the great tournament)
- You must follow the prototype defined in Section “4. Computer Player” to implementIt should produce valid moves, and it should not modify the input game boardNote that your computer player may play first or play second, meaning that yourchess pieces may start from the upper-left OR lower-right corner.
- Your “submitted” computer function shouldn’t contain any print statement,otherwise, the tournament system may wrongly judge your results. Note that youFor fairness in the competition, your computer player must produce an outputwithin a reasonable amount of time, i.e., within 5 seconds on the lab’s computer.You need to carefully test your code to make sure your code won’t damage ourtournament system, e.g., the “array out of bounds” error!!!
- No “main() function” in your submitted files for the computer tournament part.Please note that if your program does not follow any one of the above requirements, youmay get zero points for the “human v.s. computer” part or the tournament.ESTR1002, 2024-2025 Course ProjecPage 10 of 13
- SubmissioWe have created two submission boxes on Blackboard:
Basic program: the entire program, including all .c and .h files that supports
“human vs. human” and “human vs. computer” andGreat tournament: your code ONLY for the computer player to attend thetournament.
5.1 Submission format for basic program
Your submission for the basic program should be a single zip file named as
basic_<studentID>.zip (e.g., basic_1155123456.zip)
which contains and should only contain all .h and .c files in your project. The TA willdownload your submission files from Blackboard and compile them during the projectdemo to form an executable game using gcc, CodeBlocks, or Visual Studio for testing.
5.2 Submission format for the great tournament
Your submission for the great tournament should contain only two files:aiplayer_<studentID>.h (e.g., aiplayer_1155123456.h)In this file, you must need to define the following function:aiplayer_<studentID>.c (e.g., aiplayer_1155123456.c)
where <studentID> is your own student ID. In this file, you may have more
functions for your main computer player function above to call.In the submitted zip file for computer player, you need to include the above .h file and allthe necessary functions inside the above .c file for your computer player to work.Toimplement a stronger computer player, you may define additional functions in your .c file.However, you mustfollow the above naming convention (i.e. add your own “_studentID”at the end of all your function names), so that your TA can take your .c file and compile itwith other student’s .c files without having any ambiguity, i.e., same function name fromdifferent students. We may deduct your project marks, if you fail to follow thisconvention.Also, use .c rather than .cpp and .C as the extension of your source code file.Submission Note: - After preparing your submission files according to the above formats, you need toupload the files (see above) to the corresponding submission boxes in blackboard.Please see blackboard for the details.- You may submit multiple times for each submission box, and we take the lastsubmission before the deadline as your submission for grading- Furthermore, we will do plagiarism checks on your submission against others and
against the Internet.
ubmission Deadline:
Pre-tournament deadline (optional): Nov 24, 11:59pm
- Ultimate deadline: Nov 27, 11:59pm
Demo day is on Nov 28 in class.ESTR1002, 2024-2025 Course ProjectPage 11 of 13GradingThis project has two parts for grading. Note again that the basic part of the project (part1 below) takes up 16% of the whole course and the bonus part (part 2 below) is extra.
Part 1: the basic game program (16%)
- The basic “human vs. human” part takes up 12% of the whole course.
- The basic “human vs. computer” part takes up another 4% of the whole course.
During the project demo (on the demo day during the last lecture), the TAs will compilyour program, and then test your program in the following ways:(i) interactively try your game with “human vs. human”;(ii) pipe some sample text files in the above format intoyour game executable and see
if the results are correct, as expected (you will learn the meaning of “pipe” in classlater); and(iii) try “human vs. computer” in your game to see if the moves selected byyouromputer player are always valid, etc.Part 2: The great tournament Please read Sec. 4.2 again for the rules of the great tournament.After all matches are completed, we will sum up the points that each student gained ashis/her total tournamentscore. Then, we will rank the students based on the total scores.Each student may then obtain extra bonus points (beyond the basic scores in the course)based onhis/her ranking; see the table below.
Ranking Bonus Credit (of thewhole course) 13.0 bonus pts2-32.2 bonus pts4-7
1.4 bonus pts8-150.6 bonus ptsESTR1002, 2024-2025 Course ProjectPage 12 of 13Project Schedule
Week Date Tasks Expected to be done 9Oct 28The project will be released on Blackboard course homepage(and will be discussed in class on Oct 28)Start to write the basic game:Function: Initialize game boardFunction: Display user interface
Start thinking over - Condition: “Location valid?”
Start thinking over how to find all squares?Etc.At home: implement the rest of the game.10 - 11 Nov 11Around this date, you should have completed the basicgame without the computer player, so that you can focuson your computer player for remained time.