Display more state including win state!
This commit is contained in:
parent
e46bc9f504
commit
87c6ae831a
|
@ -11,7 +11,14 @@
|
||||||
(define peer-mark (if initiator? 'o 'x))
|
(define peer-mark (if initiator? 'o 'x))
|
||||||
(define board (make-board))
|
(define board (make-board))
|
||||||
(define my-turn? (not initiator?))
|
(define my-turn? (not initiator?))
|
||||||
|
(define (i-won?) (board-winner? board mark))
|
||||||
|
(define (peer-won?) (board-winner? board peer-mark))
|
||||||
|
(define (display)
|
||||||
|
(board-display board)
|
||||||
|
(format #t "-> It is ~a turn\n" (if my-turn? "my" "peer's"))
|
||||||
|
(when (i-won?) (format #t "*** I won! ***\n"))
|
||||||
|
(when (peer-won?) (format #t "*** I lost! ***\n")))
|
||||||
|
(display)
|
||||||
(methods
|
(methods
|
||||||
;; The peer is telling us about the turn it took.
|
;; The peer is telling us about the turn it took.
|
||||||
[(peer-turn! x y)
|
[(peer-turn! x y)
|
||||||
|
@ -19,7 +26,7 @@
|
||||||
(begin
|
(begin
|
||||||
(board-choose! board peer-mark x y)
|
(board-choose! board peer-mark x y)
|
||||||
(set! my-turn? (not my-turn?))
|
(set! my-turn? (not my-turn?))
|
||||||
(board-display board))
|
(display))
|
||||||
(error "It's my turn!"))]
|
(error "It's my turn!"))]
|
||||||
;; TODO: This needs to go somewhere else so the peer can't move for us!
|
;; TODO: This needs to go somewhere else so the peer can't move for us!
|
||||||
[(my-turn! x y)
|
[(my-turn! x y)
|
||||||
|
@ -27,5 +34,5 @@
|
||||||
(begin
|
(begin
|
||||||
(board-choose! board mark x y)
|
(board-choose! board mark x y)
|
||||||
(set! my-turn? (not my-turn?))
|
(set! my-turn? (not my-turn?))
|
||||||
(board-display board))
|
(display))
|
||||||
(error "It's not my turn."))]))
|
(error "It's not my turn."))]))
|
||||||
|
|
Loading…
Reference in New Issue