;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-advanced-reader.ss" "lang")((modname |game(2)|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))))) ; Problem Set 10: the Game ; Drew Rankin, Ian McGathey ;; ============== These are the two predefined functions ==================== ;; You don't need to understand their code, only the contract and the purpose ;; =========================================================================== ;; ===================== You may skip to the sample code below ================ ;; get-choice: string, list of strings -> integer ;; the function displays a simple menu form with the given message ;; and a drop-down menu with the list of choices. The menu ;; initially displays "Make a choice". Once a different item is chosen, ;; that item is returned. ;; When a "Close" button is pressed, the form disappears. (define (get-choice message list-of-choices) (local ( (define the-choices (make-choice (cons "Make a choice" list-of-choices))) (define w (create-window (list (list (make-message message)) (list the-choices) (list (make-button "Close" (lambda (e) (hide-window w))))))) (define (process-result n) (cond [(> n 200) (hide-window w)] ;; timeout after 200 sec [(= (choice-index the-choices) 0) (and (sleep-for-a-while 1) (process-result (+ n 1)))] [else true]) ) ) (cond [(process-result 0) (list-ref list-of-choices (- (choice-index the-choices) 1))]))) ;; get-answer: string number -> string ;; The function displays a simple text input with a question ;; and returns the answer typed in by the user ;; The second parameter (time-delay) is the number of seconds ;; the function waits after the typing of the first character ;; before it returns the answer. If the user takes longer ;; than that, a partial answer may be returned ;; 5 sec delay is reasonable for a one-word answer (define (get-answer question time-delay) (local ((define the-answer (make-text question)) (define w (create-window (list (list the-answer) (list (make-button "Close" (lambda (e) (hide-window w))))))) (define (process-result n) (cond [(> n 200) (hide-window w)] ;; timeout after 200 sec [(string=? (text-contents the-answer) "") (and (sleep-for-a-while 1) (process-result (+ n 1)))] [else true] ;; the user starts typing ))) (cond [(process-result 0) (cond [(sleep-for-a-while time-delay) (text-contents the-answer)]) ]) )) ;; =========================== do not change anything above this line ============= ;; NOTE: The language is Advanced Student. Teachpacks: gui.ss, draw.ss ;; =========================== Your work goes here: =============================== ;; This is an example of one round of the accummulation stage of a game. ;; Your game will have multiple rounds. ;; calling a get-answer function to let the user type in their name ;; 5 is the number of seconds you expect the user to spend on typing ;; the answer (from the fist character to the last one). ;; Too short times may result in the program getting a partial answer ;; Feel free to adjust this time as needed (define character-name (get-answer "What's your name?" 3)) ;; the first list of choices: (define item-choices (list "axe" "shovel" "bow")) ; Defining an item list to store users' acquisitions in and a choice list to store users' decisions in (define item-list empty) (define choice-list empty) ;; calling "get-choice" to get the user's choice, adding the choice to ;; the list of items. (set! item-list (cons (get-choice "It's your birthday! Your father gives you a gift if your choice:" item-choices) item-list)) (sleep-for-a-while 3) (first item-list) (start 500 500) (define draw-person (and ;;Background (draw-solid-rect (make-posn 0 0) 500 500 'lightblue) (draw-solid-rect (make-posn 0 400) 500 100 'green) ;;Body (draw-solid-line (make-posn 250 200) (make-posn 250 350)) ;;Legs (draw-solid-line (make-posn 250 350) (make-posn 280 475)) (draw-solid-line (make-posn 250 350) (make-posn 220 475)) ;;Head (draw-solid-disk (make-posn 250 200) 30 'white) (draw-circle (make-posn 250 200) 30 'black) (draw-solid-disk (make-posn 240 190) 2 'black) (draw-solid-disk (make-posn 260 190) 2 'black) (draw-solid-line (make-posn 242 212) (make-posn 258 212)) (draw-solid-line (make-posn 242 212) (make-posn 240 210)) (draw-solid-line (make-posn 258 212) (make-posn 260 210)) ;;Arms (draw-solid-line (make-posn 250 230) (make-posn 300 340)) (draw-solid-line (make-posn 250 230) (make-posn 200 340)) ) ) ;; using string-append to combine strings. In this case the st(first item-list)rings are: ;; the character name, " now has a ", and the newly-added item in the ;; items list (define message (string-append character-name " now has a " (first item-list))) ;;item ;; draws a string on the canvas at the given position ;; no control over the font or the color, sorry... ;; you might want to add a drawing, tooitem (draw-solid-string (make-posn 20 20) message) (define draw-item (cond [(string=? (first item-list) "axe") (and (draw-solid-rect (make-posn 205 220) 2 130 'brown) (draw-solid-rect (make-posn 207 225) 6 30 'gray) (draw-solid-rect (make-posn 185 225) 20 30 'gray) (draw-solid-rect (make-posn 175 216) 20 50 'gray) ) ] [(string=? (first item-list) "shovel") (and (draw-solid-rect (make-posn 205 310) 2 130 'brown) (draw-solid-rect (make-posn 192 440) 30 30 'gray) (draw-solid-disk (make-posn 206 470) 14 'gray) ) ] [(string=? (first item-list) "bow") (and (draw-solid-rect (make-posn 203 305) 5 45 'tan) (draw-solid-rect (make-posn 200 315) 8 25 'brown) (draw-solid-line (make-posn 205 305) (make-posn 212 260)) (draw-solid-line (make-posn 212 260) (make-posn 220 240)) (draw-solid-line (make-posn 205 350) (make-posn 212 390)) (draw-solid-line (make-posn 212 390) (make-posn 220 410)) (draw-solid-line (make-posn 220 410) (make-posn 220 240)) ) ] ) ) (sleep-for-a-while 2) (clear-solid-string (make-posn 20 20) message) (draw-solid-rect (make-posn 0 0) 500 40 'lightblue) (define armour-choices (list "football pads" "a bucket" "hockey gloves")) (set! item-list (cons (get-choice "You have enough money in your pocket for some armour. You go to Crazy Ackbar's Armour Emporium. You can afford one of these:" armour-choices) item-list )) (sleep-for-a-while 3) (define armour-message (string-append character-name " now has " (first item-list))) (draw-solid-string (make-posn 20 20) armour-message) (define draw-armour (cond [(string=? (first item-list) "football pads") (and (draw-solid-rect (make-posn 246 240) 8 55 'white) (draw-solid-rect (make-posn 230 234) 40 8 'white) (draw-solid-rect (make-posn 230 234) 8 16 'white) (draw-solid-rect (make-posn 262 234) 8 16 'white) ) ] [(string=? (first item-list) "a bucket") (and (draw-solid-rect (make-posn 225 130) 50 55 'darkgray) (draw-circle (make-posn 250 195) 28 'darkgray) ) ] [(string=? (first item-list) "hockey gloves") (and (draw-solid-rect (make-posn 290 330) 17 20 'blue) (draw-solid-rect (make-posn 285 330) 5 5 'blue) (draw-solid-rect (make-posn 190 330) 17 20 'blue) (draw-solid-rect (make-posn 207 330) 5 5 'blue) ) ] ) ) (sleep-for-a-while 3) (clear-solid-string (make-posn 20 20) armour-message) (draw-solid-rect (make-posn 0 0) 500 40 'lightblue) (set! choice-list (cons (cond [(string=? "axe" (second item-list)) (get-choice "What do you want to do with your axe?" (list "gather wood" "kill zombies" "hunt for food"))] [(string=? "shovel" (second item-list)) (get-choice "What do you want to do with your shovel?" (list "kill zombies" "mine for stone" "dig a trap for food"))] [(string=? "bow" (second item-list)) (get-choice "what do you want to do with your bow?" (list "shoot some food" "kill zombies" "shoot arrows at a wall to make a ladder"))] ) choice-list) ) (sleep-for-a-while 3) (define choice-1-list-print (list (cond [(string=? "gather wood" (first choice-list)) (draw-solid-string (make-posn 20 20) (string-append character-name " now has some wood "))] [(string=? "kill zombies" (first choice-list)) (draw-solid-string (make-posn 20 20)(string-append character-name " now has zombie heads "))] [(string=? "hunt for food" (first choice-list)) (draw-solid-string (make-posn 20 20)(string-append character-name " now has slab of pork "))] [(string=? "mine for stone" (first choice-list)) (draw-solid-string (make-posn 20 20)(string-append character-name " now has stone blocks "))] [(string=? "dig a trap for food" (first choice-list)) (draw-solid-string (make-posn 20 20)(string-append character-name " fails to catch anything with the trap "))] [(string=? "shoot some food" (first choice-list)) (draw-solid-string (make-posn 20 20)(string-append character-name " now has a slab of beef "))] [(string=? "shoot arrows at a wall to make a ladder to reach an apple" (first choice-list)) (draw-solid-string (make-posn 20 20)(string-append character-name " falls and gets a concussion "))] ) ) ) (sleep-for-a-while 3) (define choice-1-list-clear (list (cond [(string=? "gather wood" (first choice-list)) (clear-solid-string (make-posn 20 20) (string-append character-name " now has some wood "))] [(string=? "kill zombies" (first choice-list)) (clear-solid-string (make-posn 20 20)(string-append character-name " now has zombie heads "))] [(string=? "hunt for food" (first choice-list)) (clear-solid-string (make-posn 20 20)(string-append character-name " now has slab of pork "))] [(string=? "mine for stone" (first choice-list)) (clear-solid-string (make-posn 20 20)(string-append character-name " now has stone blocks "))] [(string=? "dig a trap for food" (first choice-list)) (clear-solid-string (make-posn 20 20)(string-append character-name " fails to catch anything with the trap "))] [(string=? "shoot some food" (first choice-list)) (clear-solid-string (make-posn 20 20)(string-append character-name " now has a slab of beef "))] [(string=? "shoot arrows at a wall to make a ladder to reach an apple" (first choice-list)) (clear-solid-string (make-posn 20 20)(string-append character-name " falls and gets a concussion "))] ) ) ) (define (choice-1-item-list-cons choice-list) (cond [(string=? "gather wood" (first choice-list)) (set! item-list (cons "some wood " item-list))] [(string=? "kill zombies" (first choice-list)) (set! item-list (cons "zombie heads " item-list))] [(string=? "hunt for food" (first choice-list)) (set! item-list (cons "slab of pork " item-list))] [(string=? "mine for stone" (first choice-list)) (set! item-list (cons "stone blocks " item-list))] [(string=? "dig a trap for food" (first choice-list)) (set! item-list (cons "nothing " item-list))] [(string=? "shoot some food" (first choice-list)) (set! item-list (cons "slab of beef " item-list))] [(string=? "shoot arrows at a wall to make a ladder to reach an apple" (first choice-list)) (set! item-list (cons "hallucinations " item-list))] )) (choice-1-item-list-cons choice-list) (define draw-choice-1-item (cond [(string=? (first item-list) "some wood ") (draw-solid-rect (make-posn 100 350) 80 80 'brown)] [(string=? (first item-list) "zombie heads ") (and (draw-solid-disk (make-posn 80 400) 20 'darkgreen) (draw-solid-rect (make-posn 65 400) 30 30 'darkgreen) (draw-solid-disk (make-posn 72 395) 4 'black) (draw-solid-disk (make-posn 88 395) 4 'black) (draw-solid-line (make-posn 80 400) (make-posn 75 408)) (draw-solid-line (make-posn 80 400) (make-posn 85 408)) ) ] [(or (string=? (first item-list) "slab of beef ") (string=? (first item-list) "slab of pork ")) (and (draw-solid-rect (make-posn 50 380) 80 50 'darkred) (draw-solid-rect (make-posn 130 385) 20 30 'white) (draw-solid-rect (make-posn 35 385) 15 30 'white) ) ] [(string=? (first item-list) "zombie heads ") (and (draw-solid-disk (make-posn 80 400) 20 'darkgreen) (draw-solid-rect (make-posn 65 400) 30 30 'darkgreen) (draw-solid-disk (make-posn 72 395) 4 'black) (draw-solid-disk (make-posn 88 395) 4 'black) (draw-solid-line (make-posn 80 400) (make-posn 75 408)) (draw-solid-line (make-posn 80 400) (make-posn 85 408)) ) ] [(string=? (first item-list) "stone blocks ") (and (draw-solid-rect (make-posn 50 370) 50 50 'gray) (draw-solid-rect (make-posn 115 370) 50 50 'gray) (draw-solid-rect (make-posn 78 320) 50 50 'gray) ) ] [(string=? (first item-list) "hallucinations ") (and (draw-solid-rect (make-posn 235 185) 30 10 'white) (draw-solid-line (make-posn 238 188) (make-posn 244 194)) (draw-solid-line (make-posn 244 188) (make-posn 238 194)) (draw-solid-line (make-posn 252 188) (make-posn 258 194)) (draw-solid-line (make-posn 258 188) (make-posn 252 194)) ) ] [(string=? (first item-list) "nothing ") true] ) ) (sleep-for-a-while 3) (draw-solid-rect (make-posn 0 0) 500 40 'lightblue) (define hunger-message (string-append character-name " is hungry and " (cond [(or (string=? (first item-list) "slab of beef ") (string=? (first item-list) "slab of pork ") ) "eats a slab of meat"] [(string=? (third item-list) "shovel") "plants crops using a shovel"] [else "wanders off to look for food."] ) ) ) (draw-solid-string (make-posn 20 20) hunger-message) (sleep-for-a-while 3) (clear-solid-string (make-posn 20 20) hunger-message) (draw-solid-rect (make-posn 0 0) 500 40 'lightblue) (set! choice-list (cons (get-choice "It is almost nightfall and zombies are headed your way. What do you do?" (list "build shelter" "attack zombies")) choice-list)) (sleep-for-a-while 3) (define choice-3-list-draw (cond [(string=? "build shelter" (first choice-list)) (cond [(string=? "some wood " (first item-list)) (and (draw-solid-rect (make-posn 0 0) 500 500 'darkblue) (draw-solid-rect (make-posn 0 400) 500 100 'green) (draw-solid-rect (make-posn 200 250) 400 200 'brown) (draw-solid-rect (make-posn 180 230) 400 20 'darkred) (draw-solid-rect (make-posn 240 280) 60 60 'black) (draw-solid-rect (make-posn 350 280) 60 60 'black) (draw-solid-rect (make-posn 460 280) 60 60 'black) (draw-solid-disk (make-posn 270 310) 28 'white) (draw-solid-disk (make-posn 258 300) 4 'black) (draw-solid-disk (make-posn 282 300) 4 'black) (draw-solid-line (make-posn 260 324) (make-posn 280 324)) (draw-solid-line (make-posn 260 324) (make-posn 256 320)) (draw-solid-line (make-posn 280 324) (make-posn 284 320)) (draw-solid-line (make-posn 130 300) (make-posn 130 390) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 310) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 290) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 145 470) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 115 470) 'darkgreen) (draw-solid-disk (make-posn 130 280) 20 'darkgreen) (draw-solid-disk (make-posn 126 276) 3 'black) (draw-solid-disk (make-posn 140 276) 3 'black) )] [(string=? " stone blocks " (first item-list)) (and (draw-solid-rect (make-posn 0 0) 500 500 'darkblue) (draw-solid-rect (make-posn 0 400) 500 100 'green) (draw-solid-rect (make-posn 200 250) 400 200 'gray) (draw-solid-rect (make-posn 180 230) 400 20 'darkgray) (draw-solid-rect (make-posn 240 280) 60 60 'black) (draw-solid-rect (make-posn 350 280) 60 60 'black) (draw-solid-rect (make-posn 460 280) 60 60 'black) (draw-solid-disk (make-posn 270 310) 28 'white) (draw-solid-disk (make-posn 258 300) 4 'black) (draw-solid-disk (make-posn 282 300) 4 'black) (draw-solid-line (make-posn 260 324) (make-posn 280 324)) (draw-solid-line (make-posn 260 324) (make-posn 256 320)) (draw-solid-line (make-posn 280 324) (make-posn 284 320)) (draw-solid-line (make-posn 130 300) (make-posn 130 390) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 310) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 290) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 145 470) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 115 470) 'darkgreen) (draw-solid-disk (make-posn 130 280) 20 'darkgreen) (draw-solid-disk (make-posn 126 276) 3 'black) (draw-solid-disk (make-posn 140 276) 3 'black) )] [(string=? "zombie heads " (first item-list)) (and (draw-solid-rect (make-posn 0 0) 500 500 'darkblue) (draw-solid-rect (make-posn 0 400) 500 100 'green) (draw-solid-rect (make-posn 200 250) 400 200 'darkgreen) (draw-solid-disk (make-posn 220 270) 4 'black) (draw-solid-disk (make-posn 250 340) 4 'black) (draw-solid-disk (make-posn 400 360) 4 'black) (draw-solid-rect (make-posn 240 280) 60 60 'black) (draw-solid-rect (make-posn 350 280) 60 60 'black) (draw-solid-rect (make-posn 460 280) 60 60 'black) (draw-solid-disk (make-posn 270 310) 28 'white) (draw-solid-disk (make-posn 258 300) 4 'black) (draw-solid-disk (make-posn 282 300) 4 'black) (draw-solid-line (make-posn 260 324) (make-posn 280 324)) (draw-solid-line (make-posn 260 324) (make-posn 256 320)) (draw-solid-line (make-posn 280 324) (make-posn 284 320)) (draw-solid-line (make-posn 130 300) (make-posn 130 390) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 70 310) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 70 290) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 145 470) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 115 470) 'darkgreen) (draw-solid-disk (make-posn 130 280) 20 'darkgreen) (draw-solid-disk (make-posn 126 276) 3 'black) (draw-solid-disk (make-posn 140 276) 3 'black))] [(or (string=? "slab of pork " (first item-list)) (string=? "slab of beef ")) (and (draw-solid-rect (make-posn 0 0) 500 500 'darkblue) (draw-solid-rect (make-posn 0 400) 500 100 'green) (draw-solid-rect (make-posn 160 280) 400 140 'white) (draw-solid-rect (make-posn 200 250) 400 200 'darkred) (draw-solid-rect (make-posn 240 280) 60 60 'black) (draw-solid-rect (make-posn 350 280) 60 60 'black) (draw-solid-rect (make-posn 460 280) 60 60 'black) (draw-solid-disk (make-posn 270 310) 28 'white) (draw-solid-disk (make-posn 258 300) 4 'black) (draw-solid-disk (make-posn 282 300) 4 'black) (draw-solid-line (make-posn 260 324) (make-posn 280 324)) (draw-solid-line (make-posn 260 324) (make-posn 256 328)) (draw-solid-line (make-posn 280 324) (make-posn 284 328)) (draw-solid-line (make-posn 130 300) (make-posn 130 390) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 310) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 290) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 145 470) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 115 470) 'darkgreen) (draw-solid-disk (make-posn 130 280) 20 'darkgreen) (draw-solid-disk (make-posn 126 276) 3 'black) (draw-solid-disk (make-posn 140 276) 3 'black))] [(string=? "nothing " (first item-list)) (and (draw-solid-rect (make-posn 0 0) 500 500 'darkblue) (draw-solid-rect (make-posn 0 400) 500 100 'green) (draw-solid-line (make-posn 130 300) (make-posn 130 390) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 310) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 290) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 145 470) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 115 470) 'darkgreen) (draw-solid-disk (make-posn 130 280) 20 'darkgreen) (draw-solid-disk (make-posn 126 276) 3 'black) (draw-solid-disk (make-posn 140 276) 3 'black) (draw-solid-line (make-posn 180 300) (make-posn 180 390) 'white) (draw-solid-line (make-posn 180 300) (make-posn 240 310) 'white) (draw-solid-line (make-posn 180 300) (make-posn 120 310) 'white) (draw-solid-line (make-posn 180 390) (make-posn 190 470) 'white) (draw-solid-line (make-posn 180 390) (make-posn 165 470) 'white) (draw-solid-disk (make-posn 180 280) 20 'white) (draw-solid-disk (make-posn 176 276) 3 'black) (draw-solid-disk (make-posn 190 276) 3 'black) (draw-solid-line (make-posn 230 300) (make-posn 230 390) 'darkgreen) (draw-solid-line (make-posn 230 300) (make-posn 170 310) 'darkgreen) (draw-solid-line (make-posn 230 300) (make-posn 170 290) 'darkgreen) (draw-solid-line (make-posn 230 390) (make-posn 245 470) 'darkgreen) (draw-solid-line (make-posn 230 390) (make-posn 215 470) 'darkgreen) (draw-solid-disk (make-posn 230 280) 20 'darkgreen) (draw-solid-disk (make-posn 226 276) 3 'black) (draw-solid-disk (make-posn 240 276) 3 'black) (draw-solid-line (make-posn 330 300) (make-posn 330 390) 'darkgreen) (draw-solid-line (make-posn 330 300) (make-posn 270 310) 'darkgreen) (draw-solid-line (make-posn 330 300) (make-posn 270 290) 'darkgreen) (draw-solid-line (make-posn 330 390) (make-posn 345 470) 'darkgreen) (draw-solid-line (make-posn 330 390) (make-posn 315 470) 'darkgreen) (draw-solid-disk (make-posn 330 280) 20 'darkgreen) (draw-solid-disk (make-posn 326 276) 3 'black) (draw-solid-disk (make-posn 340 276) 3 'black))] [(string=? "hallucinations " (first item-list)) true] )] [(string=? "attack zombies" (first choice-list)) (and (draw-solid-rect (make-posn 0 0) 500 500 'darkblue) (draw-solid-rect (make-posn 0 400) 500 100 'green) (draw-solid-line (make-posn 130 300) (make-posn 130 390) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 310) 'darkgreen) (draw-solid-line (make-posn 130 300) (make-posn 190 290) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 145 470) 'darkgreen) (draw-solid-line (make-posn 130 390) (make-posn 115 470) 'darkgreen) (draw-solid-disk (make-posn 130 280) 20 'darkgreen) (draw-solid-disk (make-posn 126 276) 3 'black) (draw-solid-disk (make-posn 140 276) 3 'black) (draw-solid-line (make-posn 180 300) (make-posn 180 390) 'white) (draw-solid-line (make-posn 180 300) (make-posn 240 310) 'white) (draw-solid-line (make-posn 180 300) (make-posn 120 310) 'white) (draw-solid-line (make-posn 180 390) (make-posn 190 470) 'white) (draw-solid-line (make-posn 180 390) (make-posn 165 470) 'white) (draw-solid-disk (make-posn 180 280) 20 'white) (draw-solid-disk (make-posn 176 276) 3 'black) (draw-solid-disk (make-posn 190 276) 3 'black) (draw-solid-line (make-posn 230 300) (make-posn 230 390) 'darkgreen) (draw-solid-line (make-posn 230 300) (make-posn 170 310) 'darkgreen) (draw-solid-line (make-posn 230 300) (make-posn 170 290) 'darkgreen) (draw-solid-line (make-posn 230 390) (make-posn 245 470) 'darkgreen) (draw-solid-line (make-posn 230 390) (make-posn 215 470) 'darkgreen) (draw-solid-disk (make-posn 230 280) 20 'darkgreen) (draw-solid-disk (make-posn 226 276) 3 'black) (draw-solid-disk (make-posn 240 276) 3 'black) (draw-solid-line (make-posn 330 300) (make-posn 330 390) 'darkgreen) (draw-solid-line (make-posn 330 300) (make-posn 270 310) 'darkgreen) (draw-solid-line (make-posn 330 300) (make-posn 270 290) 'darkgreen) (draw-solid-line (make-posn 330 390) (make-posn 345 470) 'darkgreen) (draw-solid-line (make-posn 330 390) (make-posn 315 470) 'darkgreen) (draw-solid-disk (make-posn 330 280) 20 'darkgreen) (draw-solid-disk (make-posn 326 276) 3 'black) (draw-solid-disk (make-posn 340 276) 3 'black))] )) (define choice-3-list-print (cond [(string=? "build shelter" (first choice-list)) (draw-solid-string (make-posn 20 20) (string-append character-name " builds a shelter out of " (cond [(or (string=? "some wood " (first item-list)) (string=? " stone blocks " (first item-list))) " (first item-list) and isn't eaten, phew."] [(string=? "zombie heads " (first item-list)) "slain zombies' heads, which the zombies don't recognize as food and thus don't try to eat."] [(or (string=? "slab of pork " (first item-list)) (string=? "slab of beef " (first item-list))) "meat, which the zombies eat. You fight them off."] [(string=? "nothing " (first item-list)) " nothing and gets eaten by the zombies "] [(string=? "hallucinations " (first item-list)) " and wanders aimlessly, avoiding the zombies largely by luck."] )))] [(string=? "attack zombies" (first choice-list)) (draw-solid-string (make-posn 20 20) (string-append character-name " attacks the zombies with their " (third item-list) " but is overrun and gets eaten by them."))] ))