[plt-scheme] program online game

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Tue Oct 13 20:45:58 EDT 2009

On Tue, Oct 13, 2009 at 11:05 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> I would try to do it in the world style and use the Javascript/Flash
> compiler some are developing.
> Start here: http://world.cs.brown.edu/

You may be able to use Moby; it's the BSL+world-to-Javascript compiler
that Jay refers to.  You can start here:


Moby takes a program written in BSL+World and translates them into a
Javascript program that can run on your web browser.  As an example,
you can look at the baduk-clock (igo Clock) example in:


You can see a demo of the program running here:


It's a game clock; note that it uses HTML input elements --- buttons
--- as its main UI.  (If you're running with a fairly modern web
browser, one of those buttons is styled using a CSS rotation

For the button with a picture, for example, something like this may work:

#lang moby

;; The world consists of a number.

;; We have two images, a plus and a minus image, that we'll plop onto
our buttons.
(define PLUS (js-img "http://boredzo.org/buttonicons/plus-8.png"))
(define MINUS (js-img "http://boredzo.org/buttonicons/minus-8.png"))

;; plus-press: world -> world
(define (plus-press w)
  (add1 w))

;; minus-press: world -> world
(define (minus-press w)
  (sub1 w))

;; draw: world -> dom-sexp
(define (draw w)
  (list (js-div '((id "main")))
        (list (js-text (format "World contains: ~a" w)))
        (list (js-button plus-press)
              (list PLUS))
        (list (js-button minus-press)
              (list MINUS))))

;; draw-css: world -> css-sexp
;; Let all text drawn in the main div have a font size of 30px.
(define (draw-css w)
  '(("main" ("font-size" "30px"))))

(js-big-bang 0
             (on-draw draw draw-css))

Moby itself is still in very rough shape and under active development;
I've got a sketch of documentation in:


which we're working to Scribble; hopefully we'll have something more
reasonable in the very near future.

But if Moby can make your Stratego program work on the web, I'd be
thrilled.  Let me know if you have any questions!

Posted on the users mailing list.