| Assignment 4: Game-Playing Agents |
|
CSE 415: Introduction to Artificial Intelligence The University of Washington, Seattle, Winter 2018 |
|
This continues the search theme of Assignments 2 and 3 and has the same associated reading:
Chapter 5 (Search) of
Introduction to
Artificial Intelligence Using Python.
|
|
Due Wednesday, February 7 via
Catalyst CollectIt
at 11:59 PM.
|
| What to Do.
In this assignment we explore two-person, zero-sum game playing using
a family of games called
"Toro-Tile Straight".
Here we put our agents into competition, adding lookahead (with the Minimax technique) and, optionally, pruning (with the alpha-beta method) and caching (with Zobrist hashing) to the search.
The assignment has two parts: creating your agent and engaging your agent in a first round of competitive play.
|
| PART I: Creating a Game-Playing Agent (80 points).
Create a program implementing an agent that can participate in a game of Toro-Tile Straight (defined below). Your program should consist of a single file, with a name of the form [UWNetID]_TTS_agent.py, where [UWNetID] is your own UWNetID. For example, my file would have tanimoto_TTS_agent.py for its name. Although you create one Python file for this assignment, it will contain a collection of specific functions, for playing games of "Toro-Tile Straight". We define a Toro-Tile Straight game as a kind of generalized K-in-a-Row with the following features:
You can see a full transcript of a sample game here. The two agents that played this game are very dumb, but they followed the rules. The code for each of these agents is part of the starter code. You can use this code to organize the required functions, adding to them to create a good player. It will be essential that your program use the specified representation of states, so that it is compatible with all the other A4 game agents developed in the class. Here is some code for representing states of the game. Your program should be designed to anticipate time limits on moves. There are two aspects to this: (1) use iterative deepening search, and (2) poll a clock frequently in order to return a move before time runs out.
In addition to being able to play the game, your program should make an utterance --- that is, a comment in each move, as if participating in a dialog. Ideally, your program would 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 take_a_turn 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 tanimoto_TTS.py. This will facilitate your player's being part of the class tournament.
|
| Potentially Useful Python Technique
When one of the game master programs calls your take_turn function or a testing program calls your tryout function, you may convert the current_state object into your own derived subclass object as follows, assuming your own State class is named My_TTS_State: current_state.__class__ = My_TTS_StateThen you will be able to invoke your own methods on it, such as static_eval. |
Required and Optional Features
The following features either must be implemented or
may be implemented.
|
| PART II: Game Transcript (20 points).
Follow the directions below to produce a transcript of a match between your agent and another student's agent. Using the timed_tts_game_master.py program to run a Gold Rush 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 White and your opponent plays Black. Use the following game instance for your match. For this run, you should set a time limit of 1.00 seconds per move. This can be specified on the command line when you run timed_tts_game_master.py. Here is the starter code for this assignment The following is the representation of the initial board in a TTS game we are calling "Gold Rush" in which the objective is to get a (connected) line segment of five tiles. The line may go horizontally, vertically, or diagonally.
[[['-',' ',' ','-',' ',' ','-'],
[' ',' ',' ',' ',' ',' ',' '],
[' ',' ',' ',' ',' ',' ',' '],
['-',' ',' ','-',' ',' ','-'],
[' ',' ',' ',' ',' ',' ',' '],
[' ',' ',' ',' ',' ',' ',' '],
['-',' ',' ','-',' ',' ','-']], "W"]
Note that in the following state, White has just won, because there is a
diagonal line of Ws that starts near the lower left corner of
the space, and continues up and to the right, wrapping around twice in
the toroidal space (once from right to left, and once from top to bottom).
With the upper-left square (which happens to be forbidden in this game) at row 0, column 0,
we can describe White's winning line as this sequence of locations:
[(3,5), (2,6), (1,0), (0, 1), (6, 2)]
[[['-','W',' ','-',' ',' ','-'],
['W',' ',' ',' ',' ',' ','B'],
[' ',' ',' ',' ','B','B','W'],
['-',' ',' ','-',' ','W','-'],
[' ',' ',' ',' ',' ',' ',' '],
[' ',' ','B',' ',' ' ' ',' '],
['-',' ','W','-',' ',' ','-']], "B"]
It is not required that the line of tiles involve the toroidal wraparound.
Five in a line somewhere near the middle of the board could also win, for example.
However, the wraparound feature can often help to open up many more possibilities for winning.
The timed_tts_game_master program will automatically generate an HTML file containing a formatted game transcript of your game. Turn in that HTML file. |
| Competition Option.
You can earn extra credit by having your agent participate in a competition. To enter the competition, first your agent must qualify, and then you submit your evidence of qualification. For your agent to qualify, you must submit game transcripts for two games that meet the following criteria.
|
| What to Turn In.
Turn in at least one Python file (the one for your agent). If you have created one or two new Python files that your agent needs to import, include those as well (named properly). Do not turn in any of the starter code files. Turn in either one or two game files (Two if your agent has qualified and you are entering it in the competition.) The game files are the HTML files that are automatically created when you match up your player with the opponent. |
| Updates and Corrections:
The name of the function for making your move should be The times should be in seconds (not milliseconds) for the take_turn function, so that we are using seconds everywhere in the assignment. The deadline was moved back from Feb. 5 to Feb. 7. The main program name was clarified on Jan. 31, and it should be of the form [UWNetID]_TTS_agent.py. If necessary, additional updates and corrections will be posted here and/or mentioned in class, in GoPost, or via the mailing list. |
| Feedback Survey
After submitting your solution, please answer this survey |