clicking in the whitespace between circles no longer counts as your turn
svn: r11990
This commit is contained in:
parent
95fa65b7b3
commit
161f9301f4
|
@ -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,
|
This enables you to make test cases with different size boards,
|
||||||
making some of the test cases much easier to manage.
|
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)
|
[(equal? evt 'button-up)
|
||||||
(cond
|
(cond
|
||||||
[(equal? 'playing (world-state world))
|
[(equal? 'playing (world-state world))
|
||||||
|
(cond
|
||||||
|
[(point-in-circle? (world-board world) x y)
|
||||||
(move-cat
|
(move-cat
|
||||||
(make-world (add-obstacle (world-board world) x y)
|
(make-world (add-obstacle (world-board world) x y)
|
||||||
(world-cat world)
|
(world-cat world)
|
||||||
|
@ -631,6 +633,8 @@ making some of the test cases much easier to manage.
|
||||||
(world-size world)))]
|
(world-size world)))]
|
||||||
[else
|
[else
|
||||||
world])]
|
world])]
|
||||||
|
[else
|
||||||
|
world])]
|
||||||
[else
|
[else
|
||||||
world]))
|
world]))
|
||||||
|
|
||||||
|
@ -833,6 +837,29 @@ making some of the test cases much easier to manage.
|
||||||
(list (make-cell (make-posn 0 0) true)
|
(list (make-cell (make-posn 0 0) true)
|
||||||
(make-cell (make-posn 0 1) false)))
|
(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
|
'playing
|
||||||
board-size))]
|
board-size))]
|
||||||
|
|
||||||
(and
|
(and ;((lambda (x) true) (time (build-table initial-world))) ;((lambda (x) true) (time (build-table/fast initial-world)))
|
||||||
|
|
||||||
;; illustrates the speedup for state-based dfs
|
|
||||||
;((lambda (x) true) (time (build-table initial-world)))
|
|
||||||
;((lambda (x) true) (time (build-table/fast initial-world)))
|
|
||||||
|
|
||||||
(big-bang (world-width board-size)
|
(big-bang (world-width board-size)
|
||||||
(world-height board-size)
|
(world-height board-size)
|
||||||
1
|
1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user