#1. Design and implement a function (ttt3x3n.lisp) to set the game to be run the game (computer versus computer) n times, to collect the statistics of run-times to be displayed. The program will have one argument n to run the function ttt3x3 n times (where n could be any positive integer).
To run ttt3x3n program n=4 times for test case:
(ttt3x3n 4)
Program function to run: ttt3x3n
Program file: ttt3x3n.lisp
Program run-log: ttt3x3n-log.txt
You should modify the program to set the first player X and the second player to be O and to run the program (so that the program will not ask the user to set who is X or O).
Program Listing (ttt3x3n.lisp)
Program run: try with n=4. Also submit the program-run (log) in a text file (e.g., ttt3x3n-log.txt)
If the run-result is too long (more than 1 page, then copy and paste only the first 10 lines and the last 10 lines here (in max 1/2 page). Please submit the complete output (run-log) of the program run in a log file (e.g., ttt3x3n-log.txt).
#2. Design and implement ttt4x4n.lisp from ttt3x3n.lisp program.
Modify the program (ttt3x3.lisp as your base) to implement ttt4x4.lisp to handle the tic-tac-toe game in 4×4 board. To run the game tic-tac-toe in 4×4 for computer vs computer ttt game. To run: (ttt4x4n)
Program function to run: ttt4x4n
Program file: ttt4x4n.lisp
Program run-log: ttt4x4n-log.txt
Warning: You should use the sample code provided (ttt.lisp) as your base code for this part. Otherwise, not only this part but also this assignment will be set to 0. Do your own work individually.
** State (Yes or No) for each function to be modified or not
Modified? Yes/No
Function
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
(defun generate-board ()(loop repeat 9 collect nil))
(defparameter *straights* …)
(defparameter *current-player* ‘x)
(defun get-board-elt (n board)(nth (1- n) board))
(defun legal-p (n board)(null (get-board-elt n board)))
(defun set-board-elt (n board symbol) …)
(defun list-legal-moves (board) …)
(defun get-random-element (lst)(nth (random (length lst)) lst))
(defun multi-non-nil-eq (lst) …)
(defun elements-of-straights (board) … )
(defun find-winner (board) … )
(defun set-player (mark) … )
(defun player-move (board symbol) …)
(defun computer-move (board symbol) … )
(defun computer-move-p (current-player autoplay-x-p autoplay-o-p) …)
(defun perform-turn (current-player board autoplay-x-p autoplay-o-p) …)
(defun switch-player () …)
(defun display-board (board) … )
(defun tic-tac-toe () …)
Program Listing (ttt4x4.lisp)
Program run (ttt4x4-log.txt)
#3. A Heuristic for ttt3x3nh
The ttt3x3n.lisp program (in #1) uses a random move to select next move of each player. Your task here is to provide a better heuristic (than a random move).
(defun computer-move (board symbol)
(let ((move (get-random-element (list-legal-moves board))))
(set-board-elt move board symbol)
(format t “~%computer selects ~a~%~%” move)))
Design and implement computer-move2 (to replace computer-move) for one player (e.g., X) to provide an admissible heuristic. The other player will use the random move (computer-move). Your program should output the performance of each player (e.g., how many moves for one player to win or not for each ttt 3×3 and a summary of the n runs).
Program function to run: ttt3x3nh.lisp
Program file: ttt3x3nh.lisp
Program run-log: ttt3x3nh-log.txt
You should provide a rationale for your heuristic with an informal proof to show that it is: (a) better than random move, (b) admissible, or (c) consistent. Note that (a) is a minimal requirement for this part whereas (b) or (c) is optional and for bonus points.
Heuristic function and your rationale with informal proof
Program Listing (ttt3x3nh.lisp)
Program run ttt3x3nh-log.txt