Display more state including win state!
This commit is contained in:
parent
e46bc9f504
commit
87c6ae831a
1 changed files with 10 additions and 3 deletions
|
@ -11,7 +11,14 @@
|
|||
(define peer-mark (if initiator? 'o 'x))
|
||||
(define board (make-board))
|
||||
(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
|
||||
;; The peer is telling us about the turn it took.
|
||||
[(peer-turn! x y)
|
||||
|
@ -19,7 +26,7 @@
|
|||
(begin
|
||||
(board-choose! board peer-mark x y)
|
||||
(set! my-turn? (not my-turn?))
|
||||
(board-display board))
|
||||
(display))
|
||||
(error "It's my turn!"))]
|
||||
;; TODO: This needs to go somewhere else so the peer can't move for us!
|
||||
[(my-turn! x y)
|
||||
|
@ -27,5 +34,5 @@
|
|||
(begin
|
||||
(board-choose! board mark x y)
|
||||
(set! my-turn? (not my-turn?))
|
||||
(board-display board))
|
||||
(display))
|
||||
(error "It's not my turn."))]))
|
||||
|
|
Loading…
Reference in a new issue