


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Your task in this project is to implement the game tic-tac-toe, including a simple computer player. The game is played on a 3 × 3 board; the human player ...
Typology: Lecture notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



;; a board consists of the current player, the opponent, and the ;; state of the game, where the state of the game is either ’X or ;; ’O when there is a winner, ’draw when the game is drawn, or ;; ’none when the game is in progress. ( define-struct board (player opponent winner))
;; a player is a name (’X or ’O) and a sorted list of pieces ( define-struct player (name pieces))
;; a cell is a row and column ( define-struct cell (row col))
;; There are eight winning configurations ( define winners ...)
;; winner? : (listof cells) -> (union (listof cells) false) ;; is there a winning configuration embedded in the sorted list of pieces? ;; Return the winning configuration, if it exists, otherwise return false. ( define (winner? pieces) ...)
(^1) We say that list l 1 is embedded in list l 2 if the elements of l 1 appear in l 2 in the same order as they are in l 1. For
example, ’(a b c) is embedded in ’(x a b y z c w), but not in ’(x a c y b z).
;; random-player : board -> board ;; Play a random move ( define (random-player b) ...)
(run random-player)