Prev: CP2, Next: CP4




# CP3 Project Instruction

📗 Enter your ID (the wisc email ID without @wisc.edu) here: and click (or hit the "Enter" key)
📗 You can also load from your saved file
and click .
📗 If the questions are not generated correctly, try refresh the page using the button at the top left corner.
📗 The due date (hard deadline) is August 3, late submissions to the competitive project components will not be accepted under any circumstances. The remaining assignment can be submitted to earn a maximum of 5 points before August 10 without penalty.
📗 The same ID should generate the same set of questions. Your answers are not saved when you close the browser. You could either copy and paste or load your program outputs into the text boxes for individual questions or print all your outputs to a single text file and load it using the button at the bottom of the page.
📗 Please do not refresh the page: your answers will not be saved.
📗 You should implement the algorithms using the mathematical formulas from the slides. You can use packages and libraries to preprocess and read the data and format the outputs. It is not recommended that you use machine learning packages or libraries, but you will not lose points for doing so.
📗 Please report any bugs on Piazza: Link

# Warning: please enter your ID before you start!


TODO for next year (not enforced this year): question 8 should also check if the network overfits the minimax policy with heuristic.



📗 (Introduction) In this project, you will implement the minimax algorithm with some static board evaluation function to play the Connect Four game: Wikipedia. The first player has a winning strategy, but it is difficult to compute the best responses in real time. Instead, you will use some heuristic with a depth limit to solve for approximate best responses.

📗 (Part 1) Implement the rules of the game: each player drops one piece from the top of a \(6\) row by \(7\) column board, and the first player who connects four pieces horizontally, vertically, or diagonally wins. You can try this game with a simple opponent below (click anywhere in the column to drop the piece). Implement simple heuristic that computes the largest number of connected pieces horizontally, vertically, or diagonally, \(c_{1}\) for player 1 and \(c_{2}\) for player 2, and returns \(\dfrac{1}{4} \left(c_{1} - c_{2}\right)\) and returns \(1\) if \(c_{1} = 4\) and \(-1\) if \(c_{2} = 4\).

📗 (Part 2) Implement the minimax algorithm (with or without alpha-beta pruning) with some depth limits, and use the heuristic (static board evaluation) as the value when the depth limit is reached.

Simple test set:

📗 (Competition) Submit a policy neural network to play against other students.

Your submission should contain (i) your player name (not necessarily your real name), (ii) your team (a random number between 0 and 1, rounded to four decimal places), (iv) your network weights if you are the first player, (v) [optional] your second network weights if you are the second player (if not provided, the same network will be used), and have the following format in a .txt text file:
➩ Small example:
➩ Large example:

You will play twice with each of the other players in your team and your score will be the number of wins plus \(0.5\) times the number of ties. Your project grade is based on your submission to this assignment (out of 5) plus your ranking within your team (out of 5):
Top 10% gets 5/5 in each team.
Next 10% gets 4/5 in each team.
Next 10% gets 3/5 in each team.
Next 10% gets 2/5 in each team.
Next 10% gets 1/5 in each team.
(The students who do not participate in the competition will be evenly split into each of the teams with scores of 0s when computing the rankings).

Competition VS


Wins:
Leader board:
Submissions:

Red: vs Blue: Step:

You can play against a simple minimax (with depth limit) player with a simple SBE heuristic.


You are player , and start with the following state:

# Question 1 (Part 1)

📗 [5 points] Given the following board configuration, list all possible successors if player 1 is making a move next. (7 lines, for player 1 dropping a piece from columns 0, 1, 2, ..., 6, with 42 integers on each line, 0 means empty, 1 means player 1 piece, -1 means player 2 piece).
➩ Configuration:
Hint
📗 TBA.




# Question 2 (Part 1)

📗 [10 points] Enter the heuristic (see instructions) from each of the 7 configurations in the previous question. (7 numbers between 0 and 1, rounded to 2 decimal places, on one line).
Hint
📗 TBA.




# Question 3 (Part 1)

📗 [5 points] Enter the best choice(s) of player 1's next move based on the heuristic. (integers between 0 and 6, specifying which column to drop the piece, comma separated if there are multiple).
Hint
📗 TBA.




# Question 4 (Part 2)

📗 [5 points] For each of the 100 test configurations in the instructions, enter the best choice of player 1's next move based on the heuristic. (100 lines with integers between 0 and 6, specifying which column to drop the piece, comma separated in each line if there are multiple).
Hint
📗 TBA.




# Question 5 (Part 2)

📗 [5 points] For each of the 100 test configurations in the instructions, enter the best choice of player 1's next move based on minimax algorithm with depth limit 1. (100 lines with integers between 0 and 6, specifying which column to drop the piece, comma separated in each line if there are multiple).
Hint
📗 TBA.




# Question 6 (Part 2)

📗 [20 points] For each of the 100 test configurations in the instructions, enter the best choice of player 1's next move based on minimax algorithm with depth limit 2. (100 lines with integers between 0 and 6, specifying which column to drop the piece, comma separated in each line if there are multiple).
Hint
📗 TBA.




# Question 7 (Part 2)

📗 [5 points] Enter a set of weights of your network (three matrices separated by -----, each matrix has rows separated by lines, columns separated by commas, the first matrix should be \(42\) by \(h_{1}\), second matrix should be \(h_{1}\) by \(h_{2}\), and the last matrix should be \(h_{2}\) by \(7\)). 
Hint
📗 TBA.




You can test your network by playing against it. Note: when you play as the player 1 (Red), the network will be activated on configurations where 1 means player 2 piece and -1 means player 1 piece.


You are player

# Question 8 (Part 2)

📗 [10 points] For each of the 100 test configurations in the instructions, enter the choice made by your network. (100 integers between 0 and 6, specifying which column to drop the piece, comma separated, on one line). You can compare these with the choices made by the minimax algorithm (with or without heuristic).
Hint
📗 TBA.




# Question 9 (Competition)

📗 [1 points] If you are not planning to participate in the competition, enter "0" or "none" for this question to get the point. If you are planning to participate in the competition, attach the text file you are planning to submit to Canvas to make sure if your submission has the correct format.
Hint
📗 See instructions at the top of the page.




# Question 10

📗 [1 points] Please enter any comments and suggestions including possible mistakes and bugs with the questions and the auto-grading, and materials relevant to solving the question that you think are not covered well during the lectures. If you have no comments, please enter "None": do not leave it blank.
📗 Answer: .

# Grade


 * * * *

 * * * * *

# Submission


📗 Please do not modify the content in the above text field: use the "Grade" button to update.
📗 Warning: grading may take around 10 to 20 seconds. Please be patient and do not click "Grade" multiple times.


📗 You could submit multiple times (but please do not submit too often): only the latest submission will be counted. 
📗 Please also save the text in the above text box to a file using the button or copy and paste it into a file yourself . You can also include the resulting file with your code on Canvas Assignment CP3.
📗 The competition file should be submitted to the Canvas Assignment CP3 Competition in a text file named "CP3.txt" (please do not use a different file name).
📗 You could load your answers from the text (or txt file) in the text box below using the button . The first two lines should be "##a: 11" and "##id: your id", and the format of the remaining lines should be "##1: your answer to question 1" newline "##2: your answer to question 2", etc. Please make sure that your answers are loaded correctly before submitting them.



📗 Saving and loading may take around 10 to 20 seconds. Please be patient and do not click "Load" multiple times.

# Solutions

📗 No sample solutions will be posted for these assignments.
📗 You are allowed to use code from other people (with their permission) and from the Internet, but you must and give attribution at the beginning of the your code. You are allowed to use large language models such as GPT4 to write parts of the code for you, but you have to include the prompts you used in the code submission. For example, you can put the following comments at the beginning of your code:
% Code attribution: (TA's name)'s A11 example solution.
% Code attribution: (student name)'s A11 solution.
% Code attribution: (student name)'s answer on Piazza: (link to Piazza post).
% Code attribution: (person or account name)'s answer on Stack Overflow: (link to page).
% Code attribution: (large language model name e.g. GPT4): (include the prompts you used).
📗 You can get help on understanding the algorithm from any of the office hours; to get help with debugging, please go to the TA's office hours. For times and locations see the Home page. You are encouraged to work with other students, but if you use their code, you must give attribution at the beginning of your code.





Last Updated: August 22, 2025 at 10:06 AM