From 917e18438fb09d21af3e0ebe701b98fb19af8ea6 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 13 Oct 2016 23:05:22 -0700 Subject: 3497 --- html/chessboard.mu.html | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'html/chessboard.mu.html') diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 891cdd93..d4fd58da 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -38,6 +38,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color # display the position after each move. def main [ + local-scope open-console # take control of screen, keyboard and mouse # The chessboard function takes keyboard and screen objects as 'ingredients'. @@ -55,6 +56,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ## But enough about mu. Here's what it looks like to run the chessboard program. scenario print-board-and-read-move [ + local-scope trace-until 100/app # we'll make the screen really wide because the program currently prints out a long line assume-screen 120/width, 20/height @@ -64,7 +66,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] run [ - local-scope screen:&:screen, console:&:console <- chessboard screen:&:screen, console:&:console # icon for the cursor cursor-icon:char <- copy 9251/␣ @@ -98,7 +99,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ## Here's how 'chessboard' is implemented. -type board = address:@:&:@:char +type board = &:@:&:@:char # a 2-D array of arrays of characters def chessboard screen:&:screen, console:&:console -> screen:&:screen, console:&:console [ local-scope @@ -235,10 +236,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario printing-the-board [ + local-scope + board:board <- initial-position assume-screen 30/width, 12/height run [ - local-scope - board:board <- initial-position screen:&:screen <- print-board screen:&:screen, board ] screen-should-contain [ @@ -400,11 +401,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario read-move-blocking [ + local-scope assume-screen 20/width, 2/height + source:&:source:char, sink:&:sink:char <- new-channel 2/capacity + read-move-routine:num/routine <- start-running read-move, source, screen:&:screen run [ - local-scope - source:&:source:char, sink:&:sink:char <- new-channel 2/capacity - read-move-routine:num/routine <- start-running read-move, source, screen:&:screen # 'read-move' is waiting for input wait-for-routine-to-block read-move-routine read-move-state:num <- routine-state read-move-routine @@ -473,11 +474,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario read-move-quit [ + local-scope assume-screen 20/width, 2/height + source:&:source:char, sink:&:sink:char <- new-channel 2/capacity + read-move-routine:num <- start-running read-move, source, screen:&:screen run [ - local-scope - source:&:source:char, sink:&:sink:char <- new-channel 2/capacity - read-move-routine:num <- start-running read-move, source, screen:&:screen # 'read-move' is waiting for input wait-for-routine-to-block read-move-routine read-move-state:num <- routine-state read-move-routine @@ -501,11 +502,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario read-move-illegal-file [ + local-scope assume-screen 20/width, 2/height + source:&:source:char, sink:&:sink:char <- new-channel 2/capacity + read-move-routine:num <- start-running read-move, source, screen:&:screen run [ - local-scope - source:&:source:char, sink:&:sink:char <- new-channel 2/capacity - read-move-routine:num <- start-running read-move, source, screen:&:screen # 'read-move' is waiting for input wait-for-routine-to-block read-move-routine read-move-state:num <- routine-state read-move-routine @@ -523,11 +524,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario read-move-illegal-rank [ + local-scope assume-screen 20/width, 2/height + source:&:source:char, sink:&:sink:char <- new-channel 2/capacity + read-move-routine:num <- start-running read-move, source, screen:&:screen run [ - local-scope - source:&:source:char, sink:&:sink:char <- new-channel 2/capacity - read-move-routine:num <- start-running read-move, source, screen:&:screen # 'read-move' is waiting for input wait-for-routine-to-block read-move-routine read-move-state:num <- routine-state read-move-routine @@ -546,11 +547,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario read-move-empty [ + local-scope assume-screen 20/width, 2/height + source:&:source:char, sink:&:sink:char <- new-channel 2/capacity + read-move-routine:num <- start-running read-move, source, screen:&:screen run [ - local-scope - source:&:source:char, sink:&:sink:char <- new-channel 2/capacity - read-move-routine:num <- start-running read-move, source, screen:&:screen # 'read-move' is waiting for input wait-for-routine-to-block read-move-routine read-move-state:num <- routine-state read-move-routine @@ -583,12 +584,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario making-a-move [ + local-scope assume-screen 30/width, 12/height + board:board <- initial-position + move:&:move <- new move:type + *move <- merge 6/g, 1/'2', 6/g, 3/'4' run [ - local-scope - board:board <- initial-position - move:&:move <- new move:type - *move <- merge 6/g, 1/'2', 6/g, 3/'4' board <- make-move board, move screen:&:screen <- print-board screen:&:screen, board ] -- cgit 1.4.1-2-gfad0