I am working on a big boggle game in racket for a class. I am still trying to figure out racket so I am really struggling with this. I am supposed to print out a 5x5 board with random letters in it and then I need to print out a list of lists with the characters from the board for my instructor to use in his player. However when I call the instructors-player it is generating a new list of characters. Any thoughts on what I might be doing wrong?
Creating my lists:
(define alphabet (list "B " "C " "D " "F " "G " "H " "J " "K " "L " "M " "N" "P " "R " "S " "T " "V " "W " "X " "Y " "Z "))
(define vowel (list "A " "E " "I " "O " "U "))
(define (pick-item alphabet)(list-ref alphabet (random(length alphabet))));;select element randomly from alphabet list
(define (pick-vowel vowel)(list-ref vowel (random(length vowel)))) ;;select element randomly from vowel list
(define (make-row alphabet) (list (pick-item alphabet)(pick-vowel vowel)(pick-item alphabet)(pick-vowel vowel)(pick-item alphabet))) ;;make a list of vowels and consonants
(define (make-board) (list (make-row alphabet) (make-row alphabet) (make-row alphabet) (make-row alphabet) (make-row alphabet))) ;;make a list of 5 lists for board
(define (instructors-player gameGrid) (make-board) )
Drawing the board and calling the instructors-player
(define gameGrid(draw-board (make-board)))
(instructors-player gameGrid);;call for instructors input
Try this:
(define a-board (make-board)) ; make a board
(draw-board a-board) ; draw the board
(instructors-player a-board) ; give a-board to the instructor's player
Maybe the last line needs to be:
(draw-board (instructors-player a-board))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.