Question: #lang racket ;;; Project 0 Tic-tac-toe with Racket ;;; ;;; Please immediately read README.md (provide board? next-player valid-move? make-move winner? calculate-next-move) ;; ;; Useful utility

#lang racket

;;; Project 0 Tic-tac-toe with Racket ;;; ;;; Please immediately read README.md

(provide board? next-player valid-move? make-move winner? calculate-next-move)

;; ;; Useful utility functions ;;

; Returns the number of elements in l for which the predicate f ; evaluates to #t. For example: ; ; (count (lambda (x) (> x 0)) '(-5 0 1 -3 3 4)) => 3 ; (count (lambda (x) (= x 0)) '(-5 0 1 -3 3 4)) => 1 (define (count f l) (cond [(empty? l) 0] [(f (car l)) (add1 (count f (cdr l)))] [else (count f (cdr l))]))

;; ;; Your solution begins here ;;

; Check whether a list is a valid board (define (board? lst) 'todo)

;;; From the board, calculate who is making a move this turn (define (next-player board) 'todo)

;;; If player ('X or 'O) want to make a move, check whether it's this ;;; player's turn and the position on the board is empty ('E) (define (valid-move? board row col player) 'todo)

;;; To make a move, replace the position at row col to player ('X or 'O) (define (make-move board row col player) 'todo)

;;; To determine whether there is a winner? (define (winner? board) 'todo)

;;; The board is the list containing E O X ;;; Player will always be 'O ;;; returns a pair of x and y (define (calculate-next-move board player) 'todo)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!