clicking in the whitespace between circles no longer counts as your turn

svn: r11990
This commit is contained in:
Robby Findler 2008-10-11 18:17:20 +00:00
parent 95fa65b7b3
commit 161f9301f4

View File

@ -1,6 +1,6 @@
#|
Hint: include the size of the board in your world structure
hint: include the size of the board in your world structure
This enables you to make test cases with different size boards,
making some of the test cases much easier to manage.
@ -624,6 +624,8 @@ making some of the test cases much easier to manage.
[(equal? evt 'button-up)
(cond
[(equal? 'playing (world-state world))
(cond
[(point-in-circle? (world-board world) x y)
(move-cat
(make-world (add-obstacle (world-board world) x y)
(world-cat world)
@ -631,6 +633,8 @@ making some of the test cases much easier to manage.
(world-size world)))]
[else
world])]
[else
world])]
[else
world]))
@ -833,6 +837,29 @@ making some of the test cases much easier to manage.
(list (make-cell (make-posn 0 0) true)
(make-cell (make-posn 0 1) false)))
;; point-in-circle? : board number number -> boolean
(define (point-in-circle? board x y)
(cond
[(empty? board) false]
[else
(local [(define cell (first board))
(define center (+ (cell-center-x (cell-p cell))
(* (sqrt -1) (cell-center-y (cell-p cell)))))
(define p (+ x (* (sqrt -1) y)))]
(or (<= (magnitude (- center p)) circle-radius)
(point-in-circle? (rest board) x y)))]))
(check-expect (point-in-circle? empty 0 0) false)
(check-expect (point-in-circle? (list (make-cell (make-posn 0 0) false))
(cell-center-x (make-posn 0 0))
(cell-center-y (make-posn 0 0)))
true)
(check-expect (point-in-circle? (list (make-cell (make-posn 0 0) false))
0 0)
false)
;
;
@ -997,12 +1024,7 @@ making some of the test cases much easier to manage.
'playing
board-size))]
(and
;; illustrates the speedup for state-based dfs
;((lambda (x) true) (time (build-table initial-world)))
;((lambda (x) true) (time (build-table/fast initial-world)))
(and ;((lambda (x) true) (time (build-table initial-world))) ;((lambda (x) true) (time (build-table/fast initial-world)))
(big-bang (world-width board-size)
(world-height board-size)
1