diff --git a/gib-gab-gob/game.scm b/gib-gab-gob/game.scm index ebe7705..0109a82 100644 --- a/gib-gab-gob/game.scm +++ b/gib-gab-gob/game.scm @@ -1,5 +1,6 @@ (define-module (gib-gab-gob game) - #:use-module (fibers conditions) + #:use-module (fibers) + #:use-module (fibers channels) #:use-module (goblins) #:use-module (goblins actor-lib methods) #:use-module (goblins actor-lib sealers) @@ -16,10 +17,14 @@ ((board-winner? board mark) => 'won) ((board-winner? board peer-mark) => 'lost) (else 'play))) + (define (signal-turn) + ;; any better way to do this? + (spawn-fiber (λ () (put-message my-turn+ #t)))) (define (switch-turn!) (set! %my-turn? (not %my-turn?)) - (when %my-turn? (signal-condition! my-turn+))) - (when first? (signal-condition! my-turn+)) + (when %my-turn? (signal-turn)) + #f) + (when first? (signal-turn)) (methods ;; The peer is telling us about the turn it took. [(peer-turn! x y) diff --git a/gib-gab-gob/ui/console.scm b/gib-gab-gob/ui/console.scm index dacdb1d..f13bc30 100644 --- a/gib-gab-gob/ui/console.scm +++ b/gib-gab-gob/ui/console.scm @@ -8,7 +8,6 @@ #:use-module (srfi srfi-1) #:use-module (fibers) #:use-module (fibers channels) - #:use-module (fibers conditions) #:use-module (goblins) #:export (make-initiator)) @@ -16,7 +15,7 @@ ;; A single run of the loop for a bespoke REPL for playing the game (define (%loop vat b controller my-turn+) - (wait my-turn+) + (get-message my-turn+) (with-vat vat (on (<- controller 'state) (λ (state) @@ -66,7 +65,7 @@ (define (make-initiator) (with-vat (spawn-vat #:name "Initiator Game") - (define my-turn+ (make-condition)) + (define my-turn+ (make-channel)) (define board (make-board)) (define initiator (spawn ^game-initiator ^ggg-controller board my-turn+)) (initiator/connect initiator)