Chat Noir is implemented using HtDP’s universe library: 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, code that handles drawing of the world, code that handles user input, and some code that builds an initial world and starts the game.
(require racket/list racket/math (for-syntax racket/base)) (require 2htdp/universe htdp/image lang/posn racket/contract) <world> <breadth-first-search> <board->graph> <cats-path> <drawing-the-cat> <drawing> <input> <initial-world> <tests> <go>
Each section also comes with a series of test cases that are collected into the <tests> chunk at the end of the program.
Each test case uses either test, a simple form that accepts two arguments and compares them with equal?, or test/set which accepts two lists and compares them as if they were sets.
In general, most of the test cases are left to the end of the document, organized in a series of chunks that match the functions being tested. Some of the test cases, however, provide nice illustrations of the behavior of the function and so are included in the function’s description.