[plt-scheme] thanks, but help again

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Mar 24 20:40:18 EST 2004

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])]))

No problem, but recall that public postings require public prices (= 
tax, as my kids know it :-).

1. Can you please send *your* data definitions for shot/f and ufo 
along, just to make sure they don't differ from mine,

2. Can you please send along the set of examples/tests that you 
developed for the function. That would help a lot.

3. Finally, would you mind eliminating the numbers and replacing them 
with constants, such as SHOT-WIDTH, SHOT-HIGHT, etc so that we 
understand the role of these numbers and can change them universally 
throughout your program, if needed.

Thanks. -- Matthias

Posted on the users mailing list.