diff --git a/collects/games/chat-noir/3x3-empty-board.png b/collects/games/3x3-empty-board.png similarity index 100% rename from collects/games/chat-noir/3x3-empty-board.png rename to collects/games/3x3-empty-board.png diff --git a/collects/games/chat-noir/7x7-empty-board.png b/collects/games/7x7-empty-board.png similarity index 100% rename from collects/games/chat-noir/7x7-empty-board.png rename to collects/games/7x7-empty-board.png diff --git a/collects/games/chat-noir/cat-distance-example.png b/collects/games/cat-distance-example.png similarity index 100% rename from collects/games/chat-noir/cat-distance-example.png rename to collects/games/cat-distance-example.png diff --git a/collects/games/chat-noir/5x5-empty-board.png b/collects/games/chat-noir/5x5-empty-board.png deleted file mode 100644 index 126e4074d8..0000000000 Binary files a/collects/games/chat-noir/5x5-empty-board.png and /dev/null differ diff --git a/collects/games/chat-noir/chat-noir-doc.ss b/collects/games/chat-noir/chat-noir-doc.ss index ccbe5ad660..f1d71a3a7d 100644 --- a/collects/games/chat-noir/chat-noir-doc.ss +++ b/collects/games/chat-noir/chat-noir-doc.ss @@ -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") diff --git a/collects/games/chat-noir/chat-noir-literate.ss b/collects/games/chat-noir/chat-noir-literate.ss index 113d9df894..930d24dd3b 100644 --- a/collects/games/chat-noir/chat-noir-literate.ss +++ b/collects/games/chat-noir/chat-noir-literate.ss @@ -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. ] Each section also comes with a series of test cases that are collected into the -@chunkref[] chunk at the end of the program. +@scheme[] +chunk at the end of the program. @chunk[ @@ -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[]) and then it has the @chunkref[] chunk. In the body +@scheme[]) and then it has the @scheme[] 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. diff --git a/collects/games/scribblings/chat-noir.scrbl b/collects/games/scribblings/chat-noir.scrbl index d5ba2790dc..c3ce04f24c 100644 --- a/collects/games/scribblings/chat-noir.scrbl +++ b/collects/games/scribblings/chat-noir.scrbl @@ -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") diff --git a/collects/games/chat-noir/literate-doc-wrapper.ss b/collects/scribble/lp-include.ss similarity index 55% rename from collects/games/chat-noir/literate-doc-wrapper.ss rename to collects/scribble/lp-include.ss index 030b3af629..0dc35fb3b6 100644 --- a/collects/games/chat-noir/literate-doc-wrapper.ss +++ b/collects/scribble/lp-include.ss @@ -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 ...))