1

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

Racket output when I run

Guy Coder
  • 24,501
  • 8
  • 71
  • 136

1 Answers1

0

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))
soegaard
  • 30,661
  • 4
  • 57
  • 106
  • If I do that I get two different lists without the grid I need. I tried this instead, but get an error message: `(define a-board(make-board))``(define gameGrid(draw-board(a-board)))``(instructors-player a-board)` – magictragic Oct 07 '15 at 18:44
  • I am still getting a list that doesn't make what is in my board. When I tried what I just posted I get this error: Error: application: not a procedure; expected a procedure that can be applied to arguments given: '(("P " "E " "T " "E " "G ") ("M " "U " "V " "I " "X ") ("K " "U " "D " "O " "M ") ("G " "U " "W " "A " "N ") ("W " "E " "N " "I " "M ")) – magictragic Oct 07 '15 at 18:52
  • What is the documentation of `instructors-board` ? – soegaard Oct 07 '15 at 18:53
  • What do you mean by documentation? – magictragic Oct 07 '15 at 19:06
  • You wrote: "for my instructor to use in his player." What kind of value do his player expect to get from you? – soegaard Oct 07 '15 at 19:08
  • It expects a list of 5 lists. So the output I am getting is correct, but what prints in my game board does not match what prints in my list. It generates a second list of lists. – magictragic Oct 13 '15 at 16:28