This assignment will cover some of the concepts discussed in the Adversarial Search lectures. You will be implementing game playing agents for a variant of the game Isolation.
We are also implementing this through Jupyter Notebook, so you all may find it useful to spend some time getting familiar with this software. During the first week of classes, there was an assignment [Assignment 0](https://github.gatech.edu/omscs6601/assignment_0/) that spends some time going through Python and Jupyter. If you are unfamiliar with either Python or Jupyter, please go through that assignment first!
### Table of Contents
β [Setup](#setup)
β [Jupyter](#jupyter)
β [Jupyter Tips](#jupyter-tips)
β [FAQ](#faq)
β [IDE](#IDE)
<a name=βsetupβ/></a>
## Setup
For this assignment, we **highly** recommend you to create a new environment **just** for this one assignment.
β`
conda create -n ai_env_a2 python=3.9
β`
Activate the environment:
β`
conda activate ai_env_a2
β`
In case you used a different environment name, to get a list of all environments you have on your machine, you can run `conda env list`.
Install correct package versions that will be used for visualising the game board.
β`
cd assignment_2
pip install -r requirements.txt
β`
<a name=βjupyterβ/></a>
## Jupyter
You may wish to install the `ipykernel`. This can be done via:
β`
python -m ipykernel install βuser βname ai_env_a2 βdisplay-name βPython 3.9 (AI-A2)β
β`
Further instructions are provided in the `notebook.ipynb`. Run:
β`
jupyter notebook
β`
Once started you can access [http://localhost:8888](http://localhost:8888/) in your browser.
<a name=βjupyter-tipsβ/></a>
## Jupyter Tips
Hopefully, [Assignment 0](https://github.gatech.edu/omscs6601/assignment_0/) got you pretty comfortable with Jupyter or at the very least addressed the major things that you may run into during this project. That said, Jupyter can take some getting used to, so here is a compilation of some things to watch out for specifically when it comes to Jupyter in a sort-of FAQs-like style
**1. My Jupyter notebook does not seem to be starting up or my kernel is not starting correctly.**<br />
Ans: This probably has to do with activating virtual environments. If you followed the setup instructions exactly, then you should activate your conda environment using `conda activate <environment_name>` from the Anaconda Prompt and start Jupyter Notebook from there.
**2. I was running cell xxx when I opened up my notebook again and something or the other seems to have broken.**<br />
Ans: This is one thing that is very different between IDEs like PyCharm and Jupyter Notebook. In Jupyter, every time you open a notebook, you should run all the cells that a cell depends on before running that cell. This goes for cells that are out of order too (if cell 5 depends on values set in cell 4 and 6, you need to run 4 and 6 before 5). Using the βRun Allβ command and its variants (found in the βCellβ dropdown menu above) should help you when youβre in a situation like this.
**3. The value of a variable in one of my cells is not what I expected it to be? What could have happened?** <br />
Ans: You may have run a cell that modifies that variable too many times. Look at the βcounterβ example in assignment 0. First, try running `counter = 0` and then `counter += 1`. This way, when you print counter, you get counter = 1, right? Now try running `counter += 1` again, and now when you try to print the variable, you see a value of 2. This is similar to the issue from Question 2. The order in which you run the cells does affect the entire program, so be careful.
<a name=βfaqβ/></a>
## FAQ
**1. What depth does the server call my search algorithms with?**<br />
Ans: The server will not pass a depth value to your CustomPlayer; whatever you set as the default parameter value will be used on Gradescope. Modifying this default value is extremely important in changing the performance of your agent.
**2. How does Gradescope set up and run each game?**<br />
Ans: Gradescope will run 20 games in order to determine the win ratio. Your player (CustomPlayer) will be Q1 for 10 of those games and Q2 for 10 of those games. Each player has 1 second to make each move and the first two moves (i.e. each playerβs starting location) will be randomized.
**3. Can we use multithreading of multiprocessing?**<br />
Ans: Sorry, we will not allow multithreading or multiprocessing on this Assignment. It isnβt necessary to successfully complete the Assignment.
**4. I have a question about the isolation API or the workings of the framework. Where should I learn more?**<br />
Ans: Firstly, watch the recorded YouTube video of assignment 2 where isolation API is covered. If this video and the docstrings inside isolation.py leave you with more questions, feel free to post a question on Ed and a TA will respond as soon as possible with clarifications, or come to office hours to discuss further.
**5. Can I add more functions to replace some of the existing functions? Can I import other packages as well?**<br />
Ans: No. Please do not add any more functions or imports. You should be able to finish the assignment by replacing the `NotImplementedError`.
**A more in-depth FAQ will be posted on Ed**
<a name=βIDEβ/></a>
## IDE
In case you are willing to use IDE (e.g. Pycharm) to implement your assignment in `.py` file. Please run:
β`bash
python helpers/notebook2script.py submission
β`
You will get autogenerated `submission/submission.py` file where you can write your code. However, make sure you have gone through the instructions in the `notebook.ipynb` at least once.
If you are reading this notebook on the GitHub, please go toΒ READMEΒ and follow installation instructions to set everything up locally, itβs an interactive notebook and you need a local setup to execute the cells.
Fall 2025 β CS6601 β Trail Isolation!
Instructor: Dr. Thomas Ploetz
Deadline:Β Monday, September 22nd, 7:59 am EDT
Released: Monday, September 8th, 8:00 am EDT
- Discussion is encouraged on Ed as part of the Q/A. However, all assignments should be done individually.
- Plagiarism is aΒ serious offense. You are responsible for completing your own work. You are not allowed to copy and paste, or paraphrase, or submit materials created or published by others, as if you created the materials. All materials submitted must be your own.
- All incidents of suspected dishonesty, plagiarism, or violations of the Georgia Tech Honor Code will be subject to the instituteβs Academic Integrity procedures. If we observe any (even small) similarities/plagiarisms detected by Gradescope or our TAs,Β WE WILL DIRECTLY REPORT ALL CASES TO OSI, which may, unfortunately, lead to a very harsh outcome.Β Consequences can be severe, e.g., academic probation or dismissal, grade penalties, a 0 grade for assignments concerned, and prohibition from withdrawing from the class.
Assignment Instructions
Assignment Description
The goals of this assignment are as follows:
- Verify student understanding ofΒ foundational adversarial game search algorithmsΒ introduced in lecture. (Minimax)
- ExploreΒ improved adversarial search algorithmsΒ that build upon the foundational adversarial search algorithms. (AlphaBeta)
Your task is to create an AI that can play and win a game of Trail Isolation. Your AI will be tested against several pre-baked AIs. You will implement your AI in Python 3.9, using our provided code as a starting point.
In case we havenβt got this into your heads enough:Β start early!!!Β It is entirely possible, and probably likely, that a large part of your next 2 weeks will be devoted to this assignment, but we hope that it is worth it and you will really enjoy it!
Good luck!
About the Game
Trail Isolation rules
- Pieces & board:Β Two players, one queen each, on an (N x N) grid (board size perΒ
isolation.py). - Queen movement:Β On your turn, move your queen like a chess queen: any number of open squaresΒ horizontally, vertically, or diagonally, without jumping over blocked or occupied squares.
- Permanent block:Β After you move, the square you moved from becomesΒ permanently blockedΒ for the rest of the game.
- Temporary βtrailβ block:Β All intermediate squares your queen traversed during that move (the path squares between origin and destination) becomeΒ temporarily unavailableΒ for exactly one opponent turn.
- These trail squares are unavailable to your opponent during the opponentβs immediate turn (canβt move onto or through them).
- After the opponent completes their move, those trail squaresΒ automatically revert to open.
- Destination:Β Your queen occupies the destination square (as usual).
- No passing:Β If a player hasΒ no legal move, that playerΒ loses.
- Setup:Β Starting placement and board initialization are randomized and handled by the provided code.
Example:
If you move fromΒ Β toΒ Β along the row, then:
- Β becomesΒ permanently blocked.
- Β andΒ Β are the trail and areΒ temporarily blockedΒ for the opponentβs next turn only.
- Β is your queenβs new position.
Table of contents
- Grading & Submission Policies
- Additional Helper Files
- About the Game
- Assignment contents
- Exporting the notebook
- Coding time!
- Section2a checkpoint!
- Section2b checkpoint!
- Section2c checkpoint!
- Bot fight!)
Grading & Submission Policies
The grade you receive for the assignment will be determined as follows:
| Section | Points | Condition |
|---|---|---|
| 2a | 5 points | You write an evaluation function, OpenMoveEval, which returns the number of moves that the AI minus the number of moves opponent can make, and your evaluation function performs correctly on some sample boards we provide. |
| 2a | 30 points | Your AI defeats a random player >= 90% of the time. |
| 2b | 20 points | Your AI defeats an agent with OpenMoveEval function that uses minimax to level 2 >= 80% of the times. |
| 2b | 20 points | Your AI defeats an agent with OpenMoveEval function that uses alphabeta to level 4 >= 70% of the times. |
| 2c | 20 points | Your AI defeats an agent with OpenMoveEval function that uses iterative deepening and alpha-beta pruning >= 70% of the time. |
| 2c | 5 points | Your AI defeats an agent with Peterβs secret evaluation function that uses iterative deepening and alpha-beta pruning and optimizes various aspects of the game player >= 80% of the time |
As you can see from the table there are three autograded sections, each having the following submission frequency restrictions:
- Section 2aΒ β 1 submission per 30 minutes.
- Section 2bΒ β 6 submissions per 360 minutes.
- Section 2cΒ β 6 submissions per 360 minutes.
Additional Helper Files
While youβll only have to editΒ notebook.ipynbΒ and submit the exportedΒ submission.py, there are a number of notable files:
isolation.py: Includes theΒBoardΒ class and a function for printing out a game as text. DoΒ NOTΒ change contents of this file. We have the same file on the serverβs side, so any changes will not be accounted for.notebook.ipynb: Where youβll implement the required methods for your agents.player_submission_tests.py: Sample tests to validate your agents locally.test_players.py: Contains 2 player types for you to test agents locally:RandomPlayerΒ β chooses a valid move randomly from among the available valid movesHumanPlayerΒ β allowsΒ YOUΒ to play against the AI in terminal (else useΒInteractiveGameΒ in jupyter)
Additionally, weβve included a number of local unit tests to help you test your player and evaluation function as well as to give you an idea of how the classes are used.
Setup Verification
First, letβs make sure you have installed the correct versions of all of the libraries. To install all the libraries, make sure you ranΒ pip install -r requirements.txtΒ in your Conda environment.
Simply run the cell below. You can click on the cell and pressΒ β§β©Β (Shift + Enter) to run it. If you see any warning/error messages, please make sure you have followed the installation instructions in theΒ README. In case you canβt resolve them please check out Edstem thread dedicated to βAssignment 2β.
%load_ext autoreload
%autoreload 2
%run helpers/verify_config.py # verify the environment setup
About the Game
The rules of Trail Isolation are a variation of the original Isolation game. In the original form of the game there are two players, each with their own game piece, and an (N x N) grid of squares. At the beginning of the game, the first player places their piece on any square. The second player follows suit, and places their piece on any one of the available squares. From that point on, the players alternate turns moving their piece like aΒ queen in chessΒ (any number of open squares vertically, horizontally, or diagonally).
In standard Isolation, after the piece is moved, the square that was previously occupied is blocked permanently, and cannot be used for the remainder of the game. The first player who is unable to move their queen loses.
In this variant calledΒ Trail Isolation, queens still move like chess queens, but there is an additional twist:
- TheΒ square the queen moved fromΒ is blocked permanently (same as standard Isolation).
- TheΒ squares the queen passed through during the moveΒ (the trail) becomeΒ temporarily blockedΒ for the opponentβs next turn only.
- After the opponent completes their move, those trail squares automatically open back up.
This means that each move leaves behind a trail that briefly limits the opponentβs options, introducing new strategic considerations.
For clarity, examine the scenario below:
Below is a depiction of the empty starting board position.

Q1 places their queen on the board, and Q2 follows suit. At this position, Q1 has many potential future moves (shown in light blue).

Q1 decides to move three spaces to the right. The square behind (black) becomes permanently blocked, while the intermediate squares (purple) form aΒ trailΒ that is blocked for Q2βs next turn only. The orange shows open spots available to Q2 this turn.

Q2 then moves diagonally up-left. Their starting square becomes permanently blocked (black), and their path squares form a temporary trail (purple). Meanwhile, Q1βs earlier trail is now cleared and those squares are again open.

After several turns, the board fills with permanent blocks. In this example, Q2 has no available moves left, so Q1 wins.

For more clarity, you can try playing the game against the Random Player or against yourself using the interactive tool below
# Following two lines make sure anything imported from .py scripts
# is automatically reloaded if edited & saved (e.g. local unit tests or players)
%load_ext autoreload
%autoreload 2
from board_viz import ReplayGame, InteractiveGame
from isolation import Board
from test_players import RandomPlayer
# replace RandomPlayer() with None if you want to play for both players. Or, try playing against your bot CustomPlayer(), once you have it implemented.
#ig = InteractiveGame(RandomPlayer(), show_legal_moves=True)
ig = InteractiveGame(None, show_legal_moves=True)
One other thing you can do is simulate a game between two players and replay it.
Run the next cell, click inside the text input box right above the slider and press Up or Down.
# Here is an example of how to visualise a game replay of 2 random players
game = Board(RandomPlayer(), RandomPlayer())
winner, move_history, termination = game.play_isolation(time_limit=1000, print_moves=False)
bg = ReplayGame(game, move_history, show_legal_moves=True)
bg.show_board()
Assignment contents
In this assignment you will need to implement evaluation functions and game playing methods. Your goal is to implement the following parts of the notebook:
- Evaluation functions (
OpenMoveEvalFnΒ andΒCustomEvalFnΒ if you wish to use the latter) - The minimax algorithm (
minimax) - Alpha-beta pruning (
alphabeta) - Adjust theΒ
move()Β according to section you are trying to work on.
Evaluation Functions
These functions will inform the value judgements your AI will make when choosing moves. There are 2 classes:
OpenMoveEvalFnΒ β Returns the number of available moves open for your player minus the number of moves available for opponent player. All baseline tests will use this function.Β This is mandatoryCustomEvalFnΒ β You are encouraged to create your own evaluation function here.
Notes on these classes
- You may write additional code within each class. However, we will only be invoking theΒ
score()Β function. You may not change the signature of this function. - When writing additional code please try not to copy the existing cells since they containΒ
#exportΒ comments that is used for converting the notebook toΒsubmission.pyΒ file.
CustomPlayer
This is the meat of the assignment. A few notes about the class:
- You are permitted to change the default values within the function signatures provided. In fact, when you have your custom evaluation function, you are encouraged to change the default values forΒ
__init__Β to use the new eval function. - You are free change the contents of each of the provided methods. When you are ready withΒ
alphabeta(), for example, you should updateΒmove()Β to use that function instead. - You are free to add more methods to the class.
- You may not create additional external functions and classes that are referenced from within this class.
Your agent will have a limited amount of time to act each turn (1 second). We will call these functions directly soΒ donβt modifyΒ the function names and their parameter order.
We have divided the tests into three sections (mentioned in details in next grading section below), each with their own submission limit.
These are the bare minimum requirements for your AI, and the rest is up to you. You will be scored according to how well your AI performs against some baseline AIs that we provide (seeΒ Grading). If you want to improve over the base performance, here are a few suggestions:
- Use partition techniques.
- Store the evaluation scores for past moves.
- Modify your evaluation function to account for βkiller movesβ.
- Optimize functions that are called often.
- Order nodes to maximize pruning.
We will provide you checkpoints and instructions below once you are ready to submit for each of these sections.
Exporting the notebook
In order to do get your submission file ready you will need to make sure haveΒ saved your notebookΒ and run:
# %run helpers/notebook2script section2a
Once execution is complete open autogeneratedΒ submission.pyΒ and verify that it contains all of the imports, functions and classes you are required to implement. Only then you can proceed to the Gradescope for submission.
Do NOT erase theΒ #exportΒ at the top of any cells as it is used byΒ notebook2script.pyΒ to extract cells for submission.
Coding time!
Importing External Modules
# Following two lines make sure anything imported from .py scripts
# is automatically reloaded if edited & saved (e.g. local unit tests or players)
%load_ext autoreload
%autoreload 2
import player_submission_tests as tests
from test_players import HumanPlayer, RandomPlayer
#export
import time
from isolation import Board
If you have discussed this assignment at a whiteboard level, got help from an Ed discussion or have used external resources (not provided by the instructors) that you may want to cite, please do so in the cell below as a python comment! (no need to cite python or included packages documentation)
#export
# Credits if any
# 1)
# 2)
# 3)
OpenMoveEvalFn
- This is where you write your evaluation function to evaluate the state of the board.
- The test cases below the code are expected to pass locally before you make a submission.
- Hints: Remember when calling the below helpful methods that you do need to inform both methods of who your player is (consult those methodsβ docstrings for more information).
Here are a couple methods you might find useful to implementΒ OpenMoveEvalFn():
Board.get_player_moves??
Board.get_opponent_moves??
#export
class OpenMoveEvalFn:
def score(self, game, my_player=None):
"""Score the current game state
Evaluation function that outputs a score equal to how many
moves are open for AI player on the board minus how many moves
are open for Opponent's player on the board.
Note:
If you think of better evaluation function, do it in CustomEvalFn below.
Args
game (Board): The board and game state.
my_player (Player object): This specifies which player you are.
Returns:
float: The current state's score. MyMoves-OppMoves.
"""
# TODO: finish this function!
raise NotImplementedError
######################################################################
########## DON'T WRITE ANY CODE OUTSIDE THE FUNCTION! ################
######## IF YOU WANT TO CALL OR TEST IT CREATE A NEW CELL ############
######################################################################
##### CODE BELOW IS USED FOR RUNNING LOCAL TEST DON'T MODIFY IT ######
tests.correctOpenEvalFn(OpenMoveEvalFn)
################ END OF LOCAL TEST CODE SECTION ######################
About the local test above
You should look at the test inΒ player_submission_tests.pyΒ to verify that your evaluation function is correct. If you want to edit the test (which you most definitely can), then edit the source code back inΒ player_submission_tests.py.
CustomPlayer
- CustomPlayer is the player object that will be used to play the game of isolation.
- TheΒ
move()Β method will be used to pass over to you the current state of the game board. - The content of theΒ
move()Β method will be changed by you according to the section you are attempting to pass. While you can use Iterative Deepening & Alpha-Beta (ID+AB) to beat our agents in all of the sections, going directly for ID+AB is error prone. As such, we highly recommend you to start with MiniMax (MM), then implement Alpha-Beta (AB), and only then go for ID+AB. - By default, right nowΒ
move()Β callsΒminimax()Β as you can see below. - You are not allowed to modify the function signatures or class signatures we provide. However, in case you want to have an additonal parameter you can do it at the very end of parameter list (see examples below). However, it must have a default value and you shouldnβt expect it to be passed on the server-side (i.e. Gradescope). Thus, Gradescope will be using the default value.
Originally:
def move(self, game, time_left):
...
Adding a new argument with default parameter.
def move(self, game, time_left, new_parameter=default_value):
...
Donβt do this, you will get an error in the auto-grader and lose your submission:
def move(self, game, time_left, new_parameter):
...
def move(self, new_parameter, game, time_left):
...
#export
class CustomPlayer:
# TODO: finish this class!
"""Player that chooses a move using your evaluation function
and a minimax algorithm with alpha-beta pruning.
You must finish and test this player to make sure it properly
uses minimax and alpha-beta to return a good move."""
def __init__(self, search_depth=2, eval_fn=OpenMoveEvalFn()):
"""Initializes your player.
if you find yourself with a superior eval function, update the default
value of `eval_fn` to `CustomEvalFn()`
Args:
search_depth (int): The depth to which your agent will search
eval_fn (function): Evaluation function used by your agent
"""
self.eval_fn = eval_fn
self.search_depth = search_depth
def move(self, game, time_left):
"""Called to determine one move by your agent
Note:
1. Do NOT change the name of this 'move' function. We are going to call
this function directly.
2. Call alphabeta instead of minimax once implemented.
Args:
game (Board): The board and game state.
time_left (function): Used to determine time left before timeout
Returns:
tuple: (int,int): Your best move
"""
best_move, utility = minimax(self, game, time_left, depth=self.search_depth)
return best_move
def utility(self, game, my_turn):
"""You can handle special cases here (e.g. endgame)"""
return self.eval_fn.score(game, self)
###################################################################
########## DON'T WRITE ANY CODE OUTSIDE THE CLASS! ################
###### IF YOU WANT TO CALL OR TEST IT CREATE A NEW CELL ###########
###################################################################
Minimax
- This is where you will implement the minimax algorithm. The final output of your minimax should come from this method and this is the only method that Gradescope will call when testing minimax.
- With MM implemented you are expected to pass:Β Defeat a Random Player >=90% of the time.
- Useful functions: The useful methods will probably all come from isolation.py. A couple of particularly interesting ones could beΒ
forecast_move()Β and yourΒscore()Β method from OpenMoveEvalFn. Remember the double question mark trick from Assignment 0 if you feel you are flipping between files too much!
Recommended (Approved) Resources
- Canvas Game Playing Modules
- Course AIMA Textbook 4th Edition, Section 5.1 through 5.2
#export
def minimax(player, game, time_left, depth, my_turn=True):
"""Implementation of the minimax algorithm.
Args:
player (CustomPlayer): This is the instantiation of CustomPlayer()
that represents your agent. It is used to call anything you
need from the CustomPlayer class (the utility() method, for example,
or any class variables that belong to CustomPlayer()).
game (Board): A board and game state.
time_left (function): Used to determine time left before timeout
depth: Used to track how deep you are in the search tree
my_turn (bool): True if you are computing scores during your turn.
Returns:
(tuple, int): best_move, val
"""
# TODO: finish this function!
raise NotImplementedError
######################################################################
########## DON'T WRITE ANY CODE OUTSIDE THE FUNCTION! ################
######## IF YOU WANT TO CALL OR TEST IT CREATE A NEW CELL ############
######################################################################
##### CODE BELOW IS USED FOR RUNNING LOCAL TEST DON'T MODIFY IT ######
tests.beatRandom(CustomPlayer)
tests.minimaxTest(CustomPlayer, minimax)
################ END OF LOCAL TEST CODE SECTION ######################
Section 2a Checkpoint
Now itβs a good time to submit for Section2a β SeeΒ Exporting the notebook
In case you want to submit please uncomment and run the cell below.
Your code will be generated in the folder namedΒ section2a, please uploadΒ submission.pyΒ file toΒ Gradescope
# %run helpers/notebook2script section2a
AlphaBeta
- This is where you will implement the alphabeta algorithm. The final output of your alphabeta should come from this method.
- With A/B implemented you are expected to pass:Β Minimax level 2 >= 70% of the time
- Useful functions: The useful methods will probably all come fromΒ
isolation.py. A couple of particularly interesting ones could beΒforecast_move()Β and yourΒscore()Β method from OpenMoveEvalFn. Remember the double question mark trick from Assignment 0 if you feel you are flipping between files too much!
Recommended (Approved) Resources
- Canvas Game Playing Modules
- Course AIMA Textbook 4th Edition, Section 5.3
#export
def alphabeta(player, game, time_left, depth, alpha=float("-inf"), beta=float("inf"), my_turn=True):
"""Implementation of the alphabeta algorithm.
Args:
player (CustomPlayer): This is the instantiation of CustomPlayer()
that represents your agent. It is used to call anything you need
from the CustomPlayer class (the utility() method, for example,
or any class variables that belong to CustomPlayer())
game (Board): A board and game state.
time_left (function): Used to determine time left before timeout
depth: Used to track how deep you are in the search tree
alpha (float): Alpha value for pruning
beta (float): Beta value for pruning
my_turn (bool): True if you are computing scores during your turn.
Returns:
(tuple, int): best_move, val
"""
# TODO: finish this function!
raise NotImplementedError
######################################################################
########## DON'T WRITE ANY CODE OUTSIDE THE FUNCTION! ################
######## IF YOU WANT TO CALL OR TEST IT CREATE A NEW CELL ############
######################################################################
##### CODE BELOW IS USED FOR RUNNING LOCAL TEST DON'T MODIFY IT ######
# tests.name_of_the_test #you can uncomment this line to run your test
################ END OF LOCAL TEST CODE SECTION ######################
About the lack of a local test above
Notice that we do not have any code here. We want you to learn to write your own test cases, so feel free to get creative! You can always create the test inΒ player_submission_tests.pyΒ and then run it over here in a manner identical to how local tests have been run so far.
IMPORTANT
Now remember that the server (i.e. Gradescope) usesΒ move()Β to interface with your code. So now you will need to update theΒ move()Β method (which you saw earlier in the CustomPlayer class) to callΒ alphabeta()Β so as to return the best move.
Section 2b Checkpoint
Now itβs a good time to submit for Section2b β SeeΒ Exporting the notebook
In case you want to submit please uncomment and run the cell below.
Your code will be generated in the folder namedΒ section2b. Please uploadΒ submission.pyΒ file toΒ Gradescope
# %run helpers/notebook2script section2b
That does not cover all 100 points though!
- Youβre right, and thatβs on purpose. Each of the bullets below try to walk you through how you may want to think about beating the remaining agents.
- First up is the alphabeta agent. Vanilla alphabeta (that is, alphabeta with no optimization) may not do so well against this agent. However, any agent that searches deeper with the same algorithm probably has a bigger advantage. You may learn about a method that allows your algorithm to search in such a way that you can find the maximum search depth without running out of time. This will probably come up in class or you can read through the book to find out what you are looking for.
- Next to beat is the agent with iterative deepening. This one is a little harder to think about, given that you may have used all the tools that you may think of to try a make a βbetterβ agent. But you may have just implemented the evaluation function that was discussed in class. Maybe we can do better β like checking for winning moves and prioritizing those! Or if you are feeling really creative, you can always try editing theΒ
CustomEvalFnΒ below this cell and come up with an awesome idea of your own. - Now to Peterβs agent with the secret evaluation function. Here we have nothing to tell you. Use everything in your toolbox and within the class rules to defeat it. This is by far the hardest 5 points to get! Good luck and have fun!
- Remember that you may want to edit the methods in the cell with theΒ
CustomPlayerΒ class to try and implement some of the above. You are certainly free to as long as you adhere to the general rules about editing provided code (which can be found by reading the cell above theΒCustomPlayerΒ code).
CustomEvalFn
- Edit the below to come up with your very own improved evaluation function. The typical rules about how you can and cannot edit the code we have given (namely, the function signature rules) apply here.
- IMPORTANT: Thereβs one big thing to keep in mind when the below is exported toΒ
submission.py. When the export happens, your resultingΒsubmission.pyΒ is parsed top-down, so you may have errors when trying to run that file with a custom evaluation function.- The fix is to make sure this does not happen is to follow these steps: Use βEdit->Move Cell Upβ to move the below cell to just above the first time you call CustomEvalFn (probably in CustomPlayer) -> Now runΒ
helpers/notebook.ipynbΒ -> Submit the resultingΒsubmission.pyΒ to Gradescope to test your submission.
- The fix is to make sure this does not happen is to follow these steps: Use βEdit->Move Cell Upβ to move the below cell to just above the first time you call CustomEvalFn (probably in CustomPlayer) -> Now runΒ
#export
class CustomEvalFn:
def __init__(self):
pass
def score(self, game, my_player=None):
"""Score the current game state.
Custom evaluation function that acts however you think it should. This
is not required but highly encouraged if you want to build the best
AI possible.
Args:
game (Board): The board and game state.
my_player (Player object): This specifies which player you are.
Returns:
float: The current state's score, based on your own heuristic.
"""
# TODO: finish this function!
raise NotImplementedError
######################################################################
############ DON'T WRITE ANY CODE OUTSIDE THE CLASS! #################
######## IF YOU WANT TO CALL OR TEST IT CREATE A NEW CELL ############
######################################################################
Now you may need to change theΒ move()Β method again in the CustomPlayer class. In addition, you may also need to editΒ eval_fn()Β in CustomPlayer to have your agent use the above custom evaluation function when it is playing against the test agents.
Section 2c Checkpoint
Now itβs a good time to submit for Section2c β SeeΒ Exporting the notebook
In case you want to submit please uncomment and run the cell below.
Your code will be generated in the folder namedΒ section2c. Please uploadΒ submission.pyΒ file toΒ Gradescope
# %run helpers/notebook2script section2c
Botfight (Optional, No Extra Credit)
In addition to the basic assignment, you will have the option to compete against your peers for the glory of being theΒ Fall 2025 AI-Game-Playing champ. Weβll set up a system to pit your AI against others and weβll post the top players to Ed. May the odds be ever in your favor.
Details on how to submit to the Botfight will be released on week 2 of the assignment.
Contribute to the class
If you find any typos and/or have some issues or suggestions on how to improve this or any future assignments, please feel free to make an Ed post.
Β







