| 
		Assignment 4: Advanced Game Agents
		 | 
        
| 
                CSE 415: Introduction to Artificial Intelligence The University of Washington, Seattle, Autumn 2025  | 
        
| 
                 | 
        
| 
Due Wednesday, November 12, at 11:59 PM. Partnerships are optional for
this assignment but strongly encouraged.
Complete the planning
questionnaire by Monday night, Nov. 3, for 1 point of participation
credit. (See link at the bottom of this page.)
 MODES OF PLAY: Your agent should support three modes of play: (A) Demo: Demonstration Mode, in which time used is not critical but should not take longer than 3 sec. per move. The agent will carry on a conversation during the game. (B) Autograder: In this mode, specific features will be enabled and disabled by the autograder to test your agent's functionality and assign points. (C) Competition: In this mode, the conversation will be turned off, except for each agent introducing itself. Timing will be important, to enable its use as a basis for elimination in some or all of the competition rounds.  | 
        
| 
               Here is the starter code for this assignment.  | 
        
| A. Introduction K-in-a-Row In this assignment, you'll create a program that implements an agent that can participate in a game of K-in-a-Row with Forbidden Squares (defined below). Then you'll demonstrate your agent, providing one or more transcripts of the agent playing against another agent. This game category was chosen by class vote in ED. | 
PART I: Agent Code to Play K-in-a-Row (40 points).
Your program should consist of a single file with
a name like yourUWNetID_KInARow.py where the
first author's UWNetID is used.
                Your program will consist mainly of a sub-class OurAgent of KAgent, providing collection of specific methods, for playing games of "K in a Row". We define a K in a Row game as a kind of generalized Tic-Tac-Toe with the following features: 
 The starter code consists of several files: File you will modify and turn in: 
 File you will modify and not turn in: 
 
 Files you should read and understand: 
 Other files: 
 
 Key Methods to Implement Some of the functionality you need to implement in your agent is templated or given simple versions in the starter code. For example: introduce(self) This function should return a multi-line string to introduce your agent. This should include your agent's name (you get to make this up), your name and netid, and anything else you'd like the agent to say at the start of the game. 
make_move(self, state, current_utterance, time_limit, 
          use_alpha_beta=True,
          use_zobrist_hashing=False, max_ply=3,
          special_static_eval_fn=None)
		      
                        This function determines which move to make given a game board (state). It is the main entry point into your game playing algorithm, and is called by the Game Master. 
                            If the  
                            You may assume that the    should return a list of the form [[newMove, newState, stat1, ..., stat4], myUtterance], where newMove is of the form (i, j) giving the row and column positions where the player is putting an X or O.  Here newState is
			  the result of makeing the move. It must be
			  a valid State object for the game being played.
			  myUtterance is the player's current contribution
			  to the ongoing dialog and must be a string.
			  The string should be at least one word and
			  typically a phrase that is around one line long or a sentence. It can be multiple lines if that is an important part of
			  the agent's intended behavior. (See "Utterances" below.)
			  The returned inner list that starts with newMove, may be of length 2 (typical in game-play), or
			  may be of length 6 or more, with the inclusion of "statistics" stat1 through stat4, etc.  During autograding
			  this is how you will return information that the autograder needs in order to score your agent's
			  features such as alpha-beta implementation.  For more information on these statistics, see the
			   Your minimax function and alpha-beta pruning will be graded, in-part, based on the number of cutoffs they make in a controlled game-tree search. In AUTOGRADER mode, the autograder's "special" static evaluation function has to be used by your agent. Your move-generator should consider moves in a specific order when in this mode -- the same order that they are generated (but the order not in which they are selected, which is where the randomness comes in) by the RandomPlayer agent. Also in autograder mode, it will be important to respect the max-ply value that is passed in. The parameteruse_zobrist_hashing can be used by the
autograder to specify whether or not this feature (optionally
implemented) is turned on or off for a comparative test of its
effects.  If you implement Zobrist hashing, and it works well, you
should have it on by default, and whether turned on or off, return
valid statistics.  If you do not implement Zobrist hashing, your agent
can ignore the parameter and just return the default stats (-1, for
example) that are in specified in the agent_base starter code.
			minimax(self, state, depth_remaining, time_limit, alpha, beta) 
This function should be called by  
                           The minimax function must return a move and a float value that corresponds to the evaluation of that move. static_eval(self, state, game_type=None):
                        This is your static evaluation function. Given a game state, it should return a numeric evaluation of that state where a higher value means that the state is better for X and a lower value is a state better for O. Note that this is regardless of which piece your agent is playing. For this assignment we define that X will always be the maximizing player and O always the minimizing player. In normal game-play, your agent will know what type of game is being played, because
			  the game master will provide that information via the call to your agent's  Your static evaluation function should be non-trivial and should return different evaluations for states that are clearly different. We will grade based on comparing your evaluations across states that are easily distinguished by a human as significantly better or worse, so don't worry too much about determining small differences between mostly even states. The amount of work done by your static evaluation function should depend on the type of game being played, which will be stored as a property of your agent. The game type has the value of k, which is the number of tokens in a line required to win the game. Your static evaluation function will probably need to make use of this value k. For example, if there is a line of k-1 Xs and O has not blocked the completion of k in a row, then this state should probably have a very high value.We provide little guidance for this function beyond the lecture slides. This will be the main opportunity for you to set your agent apart from the rest of the class for the tournament, so making sure that this function gives good results and runs quickly will go a long ways towards improving your agent's performance. When a call to make_move happens in AUTOGRADER mode, then your code should use the special static evaluation function given in the call instead of your own function. When not in AUTOGRADER mode, then no special static evaluation function will be provided in the call. not 
                            For our testing, you may assume that the   | 
        
| PART II: Agent Code for Dialog (30 points). | 
| Utterances:
                 Each player participates not only in the game being played, but also in a conversation that takes place at the same time. In each turn, the player returns both a move (and corresponding new game state) and a text string we call the utterance. The utterance should be "in character" with your agent's persona. Ideally, it is also somewhat intelligent in that it represents comments that are appropriate. The utterances may achieve any subset of the following behaviors: persona-specific, game-specific, game-state-specific, funny, serious, observant, didactic (teaching something about the agent technology or search techniques), or responsiveness to the utterances of the opponent. We expect each team or individual to make some effort to incorporate interesting technology or creativity into the production of the utterances. Possibilities include: (a) using an LLM with well-designed prompting to achieve both the desired persona and appropriate comments on the progress of the game; (b) designing a set of IF-THEN rules that trigger utterance patterns based on current conditions in the game or conversation; (c) instrumentation of the game search process -- numbers of states evaluated, alpha/beta cutoffs, counts of reuses of hashed state values using Zobrist hashing, etc., as the basis for insightful comments on the game. We ask you to report on how you designed your utterance-related features.  | 
        
| PART III: Reporting (30 points). | 
| HTML Transcript (10 points) | 
| 
	     Create an HTML transcript of a match between your agent and that of another person or partnership in the class. (Do not have your agent play against it self for this transcript, and do not have it play against an agent from the starter code.) It's easy to create the transcript. Simply check that the variable UseHTML is set to True in Game_Master_Offline.py. Then whatever agents and game it runs will result in an HTML file being created. The title will be generated in a way that identifies the agents and the game type. Please convert the .html file to .pdf for submissiion. The game type for this transcript should be Five-in-a-Row On Seven-by-Seven Board with Corners Forbidden. The transcript will be one of the inputs used in grading the dialog ability of your agent.  | 
		
| Running a Game
                 
                    You will normally use the file   | 
        
| Report (20 points)
                 
		  Create a report file named  
  | 
        
| Extra Credit Options
                 There are two ways to get extra credit in Part I and three ways to get extra credit in Part II. There are four more ways to obtain extra credit during the tournament: making the top 50 percent of agents, making it into the top 5 and making best agent in terms of playing the game. Note that if there are too many tied games in any round using a particular time limit per move, then the round will be repeated with a shorter time limit, so that the stronger agents get a better chance to show their strength. We will also award 5 points of extra credit to 5 of the agents that, in the opinion of the staff, are the best in terms of dialog, with features such as relevance of comments to the game, including possible comments on technical issues during the search, clarity of persona, degree of apparent engagement in the dialog with the opponent, etc. Each item is worth 5 points, it's conceivable that some agent could not only win the tournament, but score in all the other extra credit, too, for a whopping 45 points of extra credit. If you do any extra credit items, you will document them in the Extra Credit section of your report, identifying what extra credit options you completed and describing them. in Part I: 
 in Part II: 
  | 
        
| What to Turn In.
                 Turn in both your   | 
        
| For 1 point of participation credit, fill out the A4 planning questionnaire by Monday night (midnight) November 3. It's here.> | 
| Updates and Corrections
                
                If necessary, updates and corrections will be posted here and/or mentioned in class or in
                ED.
                 |