moved the newly literate program scribbled docs for the chat noir into the actual docs for the games collection

svn: r13761
This commit is contained in:
Robby Findler 2009-02-21 03:16:11 +00:00
parent fb0cc555f4
commit 7cc03cb42f
8 changed files with 36 additions and 93 deletions

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,3 +1,8 @@
#lang scribble/doc
@(require "literate-doc-wrapper.ss")
@(require scribble/lp-include scheme/include)
;; HACK: use a fake `module', which makes it possible to include a module
;; and get only its code in.
@(define-syntax-rule (module name base body ...)
(begin body ...))
@(include "chat-noir-literate.ss")

View File

@ -10,6 +10,7 @@ mzc chat-noir-doc.ss && rm -rf chat-noir-doc && scribble ++xref-in setup/xref lo
}
@;{would like to have [#:style 'toc] in the next line ... }
@title{Chat Noir}
@author[(link "http://www.eecs.northwestern.edu/~robby" "Robby Findler")
@ -41,7 +42,7 @@ the Chat Noir game in a
@section{Overview}
Chat Noir is implemented using @link["http://www.htdp.org/"]{HtDP}'s universe
library: @schememodname[teachpack/2htdp/universe]
library: @schememodname[2htdp/universe]
(although it only uses the ``world'' portions of that library).
The program is divided up into
six parts: the world data definition, an implementation of breadth-first search,
@ -64,7 +65,8 @@ and some code that builds an initial world and starts the game.
<go>]
Each section also comes with a series of test cases that are collected into the
@chunkref[<tests>] chunk at the end of the program.
@scheme[<tests>]
chunk at the end of the program.
@chunk[<tests>
<test-infrastructure>
@ -461,7 +463,7 @@ and returns a @scheme[distance-table].
As you can see, the first thing it does is bind the free variable in @scheme[bfs]
to the result of calling the @scheme[neighbors] function (defined in the chunk
@chunkref[<neighbors>]) and then it has the @chunkref[<bfs>] chunk. In the body
@scheme[<neighbors>]) and then it has the @scheme[<bfs>] chunk. In the body
it calls the @scheme[bfs] function
and then transforms the result, using
@scheme[hash-map], into a list of @scheme[cell]s.

View File

@ -1,69 +1,7 @@
#lang scribble/doc
@(require "common.ss")
@(require scheme/runtime-path (for-syntax scheme/port scheme/base scheme/path))
@(define-runtime-path cn "../chat-noir/chat-noir.ss")
@(require scribble/lp-include scheme/include)
@;{ HACK: use a fake `module', which makes it possible to include a module and get only its code in.}
@(define-syntax-rule (module name base body ...)
(begin body ...))
@gametitle["Chat Noir" "chat-noir" "Puzzle Game"]
The goal of the game is to stop the cat from escaping the board. Each
turn you click on a circle, which prevents the cat from stepping on
that space, and the cat responds by taking a step. If the cat is
completely boxed in and thus unable reach the border, you win. If the
cat does reach the border, you lose.
To get some insight into the cat's behavior, hold down the ``h''
key. It will show you the cells that are on the cat's shortest path to
the edge, assuming that the cell underneath the mouse has been
blocked, so you can experiment to see how the shortest paths change
by moving your mouse around.
The game was inspired by this one the one at
@link["http://www.gamedesign.jp/flash/chatnoir/chatnoir.html"]{Game
Design} and has essentially the same rules. It also inspired the final
project for the introductory programming course at the University of
Chicago in the fall of 2008.
@;{
This is commented out, waiting for the literate programming stuff.
This game is written in the
@link["http://www.htdp.org/"]{How to Design Programs}
Intermediate language. It is a model solution to the final project for
the introductory programming course at the University of Chicago in
the fall of 2008, as below.
@(define-syntax (m stx)
(call-with-input-file
(build-path (path-only (syntax-source stx))
'up "chat-noir" "chat-noir.ss")
(lambda (port)
(port-count-lines! port)
#`(schemeblock
#,@
(let loop ()
(let* ([p (peeking-input-port port)]
[l (read-line p)])
(cond
[(eof-object? l) '()]
[(regexp-match #rx"^[ \t]*$" l)
(read-line port)
(loop)]
[(regexp-match #rx"^ *;+" l)
=>
(lambda (m)
(let-values ([(line col pos) (port-next-location port)])
(read-line port)
(let-values ([(line2 col2 pos2) (port-next-location port)])
(cons (datum->syntax
#f
`(code:comment ,(regexp-replace* #rx" " l "\u00a0"))
(list "chat-noir.ss" line col pos (- pos2 pos)))
(loop)))))]
[else
(cons (read-syntax "chat-noir.ss" port)
(loop))])))))
#:mode 'text))
@m[]
}
@(include "../chat-noir/chat-noir-literate.ss")

View File

@ -3,10 +3,10 @@
;; Use this module to create literate doc wrappers -- files that require the
;; literate code in a way that makes it a scribble file.
(provide include chunk chunkref
(all-from-out scribble/manual))
(provide chunk (all-from-out scribble/manual))
(require scribble/manual scribble/decode scribble/struct scheme/include
(require scribble/manual scribble/decode scribble/struct
scribble/scheme
(for-syntax scheme/base syntax/boundmap))
(begin-for-syntax
@ -29,19 +29,23 @@
(identifier? #'name)
(let ([n (get-chunk-number #'name)]
[str (symbol->string (syntax-e #'name))])
(with-syntax ([tag (if (n . > . 1) (format "~a:~a" str n) str)]
[(more ...) (if (n . > . 1)
#`((subscript (smaller #,(format "~a" n))))
#`())]
[str str])
#`(make-splice
(list (make-toc-element
#f
(list (elemtag '(chunk tag)
(bold (italic (scheme name)) " ::=")))
(list (smaller (elemref '(chunk tag) #:underline? #f
str more ...))))
(schemeblock expr ...)))))]))
(if (n . > . 1)
#'(void)
(with-syntax ([tag str]
[str str])
#`(begin
;; ---- This is the new part --------
(define-syntax name (make-element-id-transformer
(lambda (stx) #'(chunkref name))))
;; ----------------------------------
(make-splice
(list (make-toc-element
#f
(list (elemtag '(chunk tag)
(bold (italic (scheme name)) " ::=")))
(list (smaller (elemref '(chunk tag) #:underline? #f
str))))
(schemeblock expr ...)))))))]))
(define-syntax (chunkref stx)
(syntax-case stx ()
@ -49,9 +53,3 @@
(identifier? #'id)
(with-syntax ([str (format "~a" (syntax-e #'id))])
#'(elemref '(chunk str) #:underline? #f str))]))
;; HACK: provide a fake `module', which makes it possible to include a module
;; and get only its code in.
(provide module)
(define-syntax-rule (module name base body ...)
(begin body ...))