Assignment 4: Game-Playing Agents |
CSE 415: Introduction to Artificial Intelligence The University of Washington, Seattle, Autumn 2012 |
![]() |
This assignment builds on Assignment 3 and has the same associated reading:
Chapter 5 (Search) of
Introduction to
Artificial Intelligence Using Python.
|
Due Monday, October 29 (changed from Friday, October 26) through
Catalyst CollectIt
at 2:00 PM.
In this assignment we expand upon the game of Tic-Tac-Toe to a more interesting generalization of it: "K-in-Row with Forbidden Squares." At the same time, we put our agents into more serious competition, adding lookahead (with the Minimax technique) and pruning (with the alpha-beta method) to the search. In addition, we add an element of fun and creativity that could serve as an opportunity to beat the Turing Test; this takes place via a more elaborate version of the "utterance feature" introduced in Assignment 3. The assignment has two parts: creating your agent and engaging your agent in a first round of competition play.
You should turn in either 2 or 3 files (depending upon whether or not you are doing the extra-credit items in Part I): (1)
a file
[YourUWNetID]KInARow.py
with your game playing agent described in Part I, and
(2) an HTML file
that provides a transcript of your agent playing against that
of another classmate, described in Part II.
If you are doing the extra credit items in Part I, then also turn in your file ExtraCredit.txt that explains
those special features of your agent.
|
PART I: Creating a K-In-A-Row Player (80 points).
Create a program implementing an agent that can participate in a game of K-in-a-Row with Forbidden Squares (defined below). Your program should consist of a single file, with a name of the form [UWNetID]KInARow.py, where [UWNetID] is your own UWNetID. For example, my file would have tanimotoKInARow.py for its name. In this part, you will create a program -- consisting mainly of a collection of specific functions, 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: (a) Just as in Tic-Tac-Toe, there are two players: one plays X and the other plays O; (b) the board is rectangular, but is not necessarily 3 by 3; it is mRows by nColumns, where these numbers are chosen by the Game Master (referee) at the beginning of the game; (c) a player wins by getting K in a row, where K is not necessarily 3; K can be any integer greater than 1 and less than or equal to the maximum of mRows and nColumns; (d) there can be "forbidden squares" on the board; these are chosen at the beginning of the game by the Game Master; a square on the board that is available is represented by a blank, whereas a forbidden square is represented by a dash "-" ; (e) there can be "handicaps" in the initial state, meaning that some X and/or O tokens can be set up on the board by the Game Master in order either shape the succeeding play or change the balance of advantage and disadvantage to the players. In addition to being able to play the game, your program should have a well-defined "personality". Some examples of possible personalities are these: friendly; harmless joker; blunt joker; paranoid; wisecracker; sage; geek; wimp; competitive freak; fortune-teller (based on the state of the game). The personality will be revealed during games via the "utterances" made by the program. (For more details, see the description of the makeMove function below.) Your program must include the following functions. You can have helper functions if you like. Please keep all the functions required by your player in just one Python file that follows the naming convention mentioned earlier. For example, my player would be in a file tanimotoKInARow.py. This will facilitate your player's being part of the class tournament.
|
PART II: Game Transcript (20 points).
Using the gameMaster.py program to run a match, create a transcript of a game between
your agent and the agent of another student in the class.
Set up the match so that your agent plays 'X' and your opponent plays 'O'.
Use the following game instance for your match.
Here is the starter code for this assignment. In addition, here is the GameMaster.py file that should be used, instead of RunKInARow. The following is the representation of the initial board in a KinARow game called "5 in a Row on 7-by-7 board with Corners Forbidden". [[['-',' ',' ',' ',' ',' ','-'], [' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' '], ['-',' ',' ',' ',' ',' ','-']], "X"]The Game Master program will automatically generate an HTML file containing a formatted game transcript of your game. Turn in that HTML file. |
Updates and Corrections: This page was last updated on October 25 at 9:20 AM (deadline changed to Oct. 29). Previously updated on Oct. 24 at 10:47 PM (added link to GameMaster.py). Also modified at 8:32 PM. (deleted mention of maxMillisecPerMove from the description of the prepare function; it's not needed there.) Updated Oct. 20, 2012. (The arguments to the prepare were redefined from those in the preliminary version of the assignment.) If necessary, more updates and corrections will be posted here and mentioned in class or on the mailing list. |