CSCI 4150: Introduction to Artificial Intelligence, Fall 2005 |
The Problem 3 webtester will first play your evaluation function against the random player and then against this reference player. Your evaluation function will play X against the random player and O against the reference player. Both your evaluation function and the reference player will be used upto depth 4 in the alpha-beta minimax search.
Here are the details of what your writeup for problem 7 should cover.
If you used an opening database, explain how you created it, i.e., which states did you include in your opening database and how did you select the moves from those states. Do not include your opening database in your writeup, but feel free to use examples from it as necessary in your writeup.
ANALYZE the resulting games, pointing out places where your evaluation function made particularly good or bad moves (and why they were good or bad moves). Also, EXPLAIN why your evaluation function caused minimax to make those moves and (for bad moves) why a better move wasn't picked. Include a transcript of these games in your writeup.
(test-myc4 eval-fn board player depth-cutoff)When you call this procedure with an evaluation function, a board state, the player to move (either the symbol X or O) and the depth cutoff, it will run the evaluation function using my alpha-beta minimax solutions. It can print out a "narration" of the alpha-beta minimax process, and, at the end, it can print out the path corresponding to an optimal game, including the alternatives that were checked.
There are several parameters that control the behavior of test-myc4:
When #t, this will print a narration of the alpha-beta minimax search process. Be forewarned that this can generate a lot of output!
When #t, prints out the path along the optimal game, along with the alternatives that were searched.
When #t, it prints the raw board state whenever it prints out a board. This can be useful when you want to do some further investigation on how your evaluation function rates moves that were not chosen.
(play-myc4 X-player-args... O-player-args)The play-myc4.com file does not load connect4.scm although it does depend on it!
To specify a player procedure requires 1 argument: the procedure itself
To specify an evaluation function, you need to give 3 arguments: the evaluation function, its depth limit, and its opening database.
If you aren't using an opening database with the evaluation function, the third argument should be the empty list.
To specify a compiled player, you must give 1 argument: the name of the compiled player procedure.
By convention, the name of the file will be the name of the compiled player procedure (without any version number or scheme extension). For example, the file whuang-cplayer.7.scm would contain the compiled player procedure whuang-cplayer.
(play-myc4 human-player c4-eval 6 '())
(play-myc4 c4-eval1 4 opening-db c4-eval2 4 opening-db)
(play-myc4 ref-cplayer c4-eval 4 '())
If #t, it prints the "raw" board state after each move. This is useful if you want to copy one of the board states so you can investigate why your evaluation function made a certain move.
If #t, it randomly permutes the children of each node before doing alpha-beta minimax. This is not done in the pre-tournament, nor will it be done in the round-robin tournament. When this is #t, your evaluation function(s) will be picking an optimal move at random. Normally, however, (when #fthe game between two players is always the same).
This web tester will run your alpha-beta minimax on a Connect 4 state using a special evaluation function that records the arguments you give it for each call. This is compared with the correct sequence of calls. It is important that you evaluate child states in the order that c4-children procedure gives them to you, or your sequence of calls will be completely different.
One thing that can causes students' code to test incorrectly is that they do not pass the correct current-player and max-player arguments to the evaluation function. The max-player argument (either the symbol X or O) is the player on whose behalf you are evaluating the board. The current-player argument (also either the symbol X or O) is the player whose turn it is to play in the given board state.
This webtester will play two games: one against the random player (you play X), and one against the reference player (you play O). Note that the reference player file does not contain the two move opening database it uses. You must beat both these players for full credit on this problem.
You can upload an evaluation function as many times as you like to the pretournament system. We will take your most recent evaluation function as of the deadline for this assignment. There is no late period for this deadline, so make sure you get your evaluation function into the pretournament.
Note: the flash applet that Kris wrote for this page still has a few little problems, but the pretournament system itself is up and working.
You can specify a move that you would like your player to make from a given state (not move sequence). Note that there are, in general, multiple move sequences that result in the same state. The problem with specifying states is that our state representation (primarily a string) takes up more memory than it should. Therefore, the opening database mechanism uses a more compact representation. In order to use the opening database mechanism, you must transform your opening database into this form.
Here are the steps to create an opening database:
(define my-db '(; X's first move should be in column 2 (" | | | | | " 2) ; if X moves in column 4, then O should move in column 7 (" | | | | | X " 7) ; if X moves in column 2, then O should move in column 3 (" | | | | | X " 3) ; X's second move, if O played in column 4, should be in column 3 (" | | | | | X O " 3) ; X's second move, if O played in column 7, should be in column 6 (" | | | | | X O" 6))
Note that your database need not be complete; you only have to specify the states that you want to. Also note that this mixes states in which X is to move with those in which O is to move. The order of the states in your list does not matter.
You can create this "board-state opening database" in a number of ways. The best way might be to write a program to generate these states (taking advantage of the support code). To generate the database above, I used the play-piece procedure in the support code. There are also procedures in the support code to transform a "movestring" into a "boardstring". See details below.
(convert-bsdb my-db "my-db.scm") ; Validating database... ; Converting database... ; Writing to file... ;Unspecified return value
WARNING — this will overwrite the filename you give it.
This file, in the above case, looks like this:
(define opening-db '((0 0 2) (0 0 15) (0 3 3) (0 3 19) (2 3 6) ))
The reason that the converted database is written to a file is that it can be somewhat large.
Note that this code will defines a variable opening-db. However, when you load a4code.com, the opening-db variable will be reset to ()! I'd suggest putting your opening database definition at the end of your file.
(movestring->boardstring "2673") ;Value: " | | | | | XO OX" (print-board (movestring->boardstring "2673")) +---------------+ 6| | 5| | 4| | 3| | 2| | 1| X O O X | +---------------+ 1 2 3 4 5 6 7
Note that the movestring "7326" would produce the same boardstring.
BTW, I modified print-board in Version 1.3 so that it can take a full state (list containing the string and a list of pieces in each column) or just the board string itself.
(db-movestring->db-boardstring "26735") ;Value: (" | | | | | XO OX" 5)
This is the same board state as above, but I've indicated that I want to move in column five after the first four moves.
This procedure has been written so that it can take a complete board state or just a boardstring. For example:
(get-opening-db-move (play-piece c4-start 'X 2)) ;Value: 3 (get-opening-db-move " | | | | | X O") ;Value: 6
(play-piece c4-start 'X 1) ;Value: (" | | | | |X " (1 0 0 0 0 0 0))