[plt-scheme] thanks, but help again

From: Connor Ferguson (psfreak at linkline.com)
Date: Mon Mar 29 21:53:02 EST 2004

I did not try the stepper. I don't know if I have any primitive operators
that require a higher level language than Beginner working on anything that
has to do with the hit-shot? Thanks though, I'll try it. I'm convinced that
I'm just not covering the right area with the box I'm drawing to represent
the place the shot must be in to register as hit.

-Connor

on 3/29/04 6:21 PM, Robby Findler at robby at cs.uchicago.edu wrote:

> Did you try the stepper with your test cases? (I'm not asking because I
> see the problem and want you to find it yourself -- I'm just curious to
> know if it would help you...)
> 
> Robby
> 
> At Mon, 29 Mar 2004 18:27:11 -0800, Connor Ferguson wrote:
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> 
>> Sorry for the delay. Things have been really hectic for me the past few
>> days.
>> 
>> Ok, here are my data definitions for UFO and shot/f
>> 
>> ;; a UFO is a shape
>> ;; (make-ufo p l w c)
>> ;; where p is a posn, l is a number, w is a number
>> ;; and c is a symbol
>> 
>> ;; a shot is a stucture
>> ;;(make-shot start l w col)
>> ;; where start is a posn (the position of the AUP)
>> ;; l is a number, w is a number, and col is a symbol
>> 
>> ;; a shot/f is either
>> ;; a shot or;
>> ;; false
>> 
>> Like Matthias said, I altered hit-shot? so that there are no numbers, only
>> constants.
>> 
>> ;; hit-shot? : shot/f ufo -> boolean
>> (define (hit-shot? shot/f ufo)
>> (cond     
>> [ (boolean? shot/f) false]
>> [ else     
>> (cond     
>> [ (and (>= (+ (posn-x (ufo-nw ufo)) (ufo-len ufo))
>> (posn-x (shot-posn shot/f)))
>> (>= (+ (posn-x (ufo-nw ufo)) (ufo-len ufo)
>> (+ (posn-x (shot-posn shot/f)) (shot-l shot/f))
>> (<= (posn-x (ufo-nw ufo))
>> (+ (posn-x (shot-posn shot/f)) (shot-l shot/f))
>> (>= (posn-y (ufo-nw ufo))
>> (posn-y (shot-posn shot/f)))
>> (>= (posn-y (ufo-nw ufo))
>> (+ (posn-y (shot-posn shot/f)) (shot-w shot/f)))) true]
>> [ else false])]))
>> 
>> I had been testing the program only by running it in the context of the
>> game, but that is not something I should not do, so I formulated these
>> tests.
>> 
>> (hit-shot? (make-shot (make-posn 10 10) 2 5 'red)
>> (make-ufo (make-posn 10 10) 22 4 'green))
>> = false
>> 
>> (hit-shot? (make-shot (make-posn 30 30) 2 5 'red)
>> (make-ufo (make-posn 10 10) 22 4 'green))
>> = false
>> 
>> (hit-shot? (make-shot (make-posn 100 100) 2 5 'red)
>> (make-ufo (make-posn 10 10) 22 4 'green))
>> = false
>> 
>> Clearly, these examples demonstrate the problem Im having. Basically,
>> everything I put into the program is evaluating to false.
>> 
>> Thank you for helping and sorry for taking so long to respond.
>> 
>> -Connor
>> 
>> on 3/24/04 5:40 PM, Matthias Felleisen at matthias at ccs.neu.edu wrote:
>> 
>>> For list-related administrative tasks:
>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>> 
>>> P.S. Congratulations to your exhibit!!!
>>> 
>>> 
>>> On Mar 24, 2004, at 8:39 PM, Connor Ferguson wrote:
>>> 
>>>> For list-related administrative tasks:
>>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>> 
>>>> Hey everybody-
>>>> 
>>>> Thanks especially to Matthias and Bruce and mathematica for your help.
>>>> My
>>>> science project of the UFO game (from HTDP) has been chosen to compete
>>>> in
>>>> the Los Angeles County Science Fair on April 13.
>>>> 
>>>> While Im very happy about this, I am still having some problems.
>>>> Whenever I
>>>> successfully modify hit-shot? to register the UFO as hit when it passes
>>>> through, it also classifies as hit when the shot has already passed and
>>>> missed and the UFO moves back to the line that the shot traveled.
>>>> Below is
>>>> my function for hit-shot? If anyone could take a look at it and please
>>>> tell
>>>> me where I may be going wrong, that would be great.
>>>> 
>>>> ;; hit-shot? : shot/f ufo -> boolean
>>>> (define (hit-shot? shot/f ufo)
>>>> (cond
>>>> [ (boolean? shot/f) false]
>>>> [ else
>>>> (cond
>>>> [ (and (>= (+ (posn-x (ufo-nw ufo)) 22)
>>>> (posn-x (shot-posn shot/f)))
>>>> (<= (posn-x (ufo-nw ufo))
>>>> (+ (posn-x (shot-posn shot/f)) 2))
>>>> (>= (posn-y (ufo-nw ufo))
>>>> (posn-y (shot-posn shot/f)))
>>>> (>= (posn-y (ufo-nw ufo))
>>>> (+ (posn-y (shot-posn shot/f)) 5))) true]
>>>> [ else false])]))
>>>> 
>>>> Thanks again
>>>> -Connor
>>>> 
>>> 
>>> 
> 



Posted on the users mailing list.