32 lines
992 B
Scheme
32 lines
992 B
Scheme
(define-module (gib-gab-gob game)
|
|
#:use-module (goblins)
|
|
#:use-module (goblins actor-lib methods)
|
|
#:use-module (goblins actor-lib sealers)
|
|
#:use-module (gib-gab-gob board)
|
|
#:export (^ggg-controller))
|
|
|
|
;; Actual Tic Tac Toe game
|
|
(define (^ggg-controller bcom initiator? peer)
|
|
(define mark (if initiator? 'x 'o))
|
|
(define peer-mark (if initiator? 'o 'x))
|
|
(define board (make-board))
|
|
(define my-turn? (not initiator?))
|
|
|
|
(methods
|
|
;; The peer is telling us about the turn it took.
|
|
[(peer-turn! x y)
|
|
(if (not my-turn?)
|
|
(begin
|
|
(board-choose! board peer-mark x y)
|
|
(set! my-turn? (not my-turn?))
|
|
(board-display board))
|
|
(error "It's my turn!"))]
|
|
;; TODO: This needs to go somewhere else so the peer can't move for us!
|
|
[(my-turn! x y)
|
|
(if my-turn?
|
|
(begin
|
|
(board-choose! board mark x y)
|
|
(set! my-turn? (not my-turn?))
|
|
(board-display board))
|
|
(error "It's not my turn."))]))
|