Tweaks and prints. Mostly works but for some reason vat promises tied to ui fiber??

- Need to figure out why main thread is blocking the vat promises from resolving.
This commit is contained in:
Vivianne 2023-07-16 20:43:40 -07:00
parent 910556a7af
commit 65497fd439
2 changed files with 16 additions and 10 deletions

View File

@ -20,7 +20,9 @@
((board-winner? board peer-mark) 'lost)
(else 'play)))
(define (signal-turn)
(format #t "signal-turn start\n")
(syscaller-free-fiber (λ () (put-message state+ (%state))))
(format #t "signal-turn end\n")
#f)
(define (switch-turn!)
(let ((new-turn (not ($ %my-turn?))))
@ -34,7 +36,8 @@
(if (not ($ %my-turn?))
(begin
(board-choose! board peer-mark x y)
(switch-turn!))
(switch-turn!)
(format #t "I, the peer, finish my turn.\n"))
(error "It's my turn!"))]
;; TODO: These need to go somewhere else so the peer can't move or init for us!
[(try-transition) 'playing]
@ -47,11 +50,14 @@
(format #t "Peer's status: ~a\n" status)
status) #:promise? #t)]
[(my-turn! x y)
(format #t "start my-turn!\n")
(if ($ %my-turn?)
(begin
(board-assert-vacant board x y)
(format #t "tell peer about it\n")
(on (<- peer 'peer-turn! x y)
(λ (_)
(format #t "peer promise resolve, then switch and return\n")
(board-choose! board mark x y)
(switch-turn!)
(%state))

View File

@ -31,13 +31,14 @@
#f))
(define (%read)
(define line (read-line (current-input-port)))
(if (string-prefix? ",q" line) #f
(let ((coords (map string->number (string-tokenize line char-set:digit))))
(if (not (= (length coords) 2))
(begin (format #t "Must be two numbers, x y; or ,quit to quit. Try again.\n")
(%prompt) (%read))
coords))))
(%prompt)
(let ((line (read-line (current-input-port))))
(if (string-prefix? ",q" line) #f
(let ((coords (map string->number (string-tokenize line char-set:digit))))
(if (not (= (length coords) 2))
(begin (format #t "Must be two numbers, x y; or ,quit to quit. Try again.\n")
(%prompt) (%read))
coords)))))
(define (%eval vat b controller coordinates)
;; weird?
@ -47,8 +48,7 @@
(λ (state) (%display b state)))))
(define (%print b state)
(%display b state)
(%prompt))
(%display b state))
(define (%prompt) (format #t "Enter your move: "))