One of the key search processes we have discussed is MiniMax search. In this program you will get some experience with the search. I have implemented a simple tic-tac-toe routine that can be found in this file prog1.lisp. The routine has a simple computer agent that plays a fairly limited game of tic-tac-toe (given the first move it chooses the center, after that it chooses randomly). Currently, the user (which we will call the student) is asked to select a move and the game proceeds until someone wins. Your job is to replace the routine makeStudentMove with an AI player that uses the MiniMax algorithm to select its next move.
To run a single game you can run (tic_tac_toe t) to have the computer move first or (tic_tac_toe nil) to have the student move first.
You should start by determining a value function that assigns value to intermediate boards. The values should at least include a value of 1 for a win for the student, -1 for a win for the computer, 0 for a tie and then reasonable values in between (e.g., if the computer can make one move to win after your move then that board should also have a value of -1, if no matter what the computer does after its move you will still be able to win that board should have a value of 1, etc.).
Next implement a MiniMax algorithm that searches through the tree of possible moves up to a certain depth (which you should add as an extra argument to the call to tic_tac_toe and pass as needed or set as a global variable). So, if you set this value to 1 when choosing the student move you will only look at the student's next move. If you set the value to 2 you will like at the students next move followed by any responses by the computer, etc. Note that this value is a limit, if it is not possible to make that many moves you should look until the game ends.
Next implement alpha-beta pruning as an option that is turned on by a global variable. So, if you define a global variable Use_Alpha_Beta_Pruning to t or nil then when it is set to t your MiniMax routine should use alpha-beta pruning and when it is nil it should not.
You will need to perform experiments and the results of those experiments with your code. Since there is randomness to this process you will need to perform multiple repeats of each experimental value. Once you have implemented your student you should report the results for each of 18 conditions, MiniMax with 1, 2, 3, 4, 5, 6, 7, 8 or 9 step lookahead with and without alpha-beta pruning. For each of these conditions you should report 1) how many games out of 100 your student won for each condition and 2) how many nodes total your search looked at during the game playing process. Plot the results using a standard tool such as Excel and discuss your results as part of your final report.
Hand in clean, nicely commented copies of all of your code (make sure to include the class code so we can tell if anything is changed). In addition, show three examples of the results produced by your code with the lookahead set to the maximum value and alpha-beta pruning. Finally, hand in your overall results as discussed in Testing above with your nice graph.