1.18.1 Overview
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 a number of parts: the world data definition, an implementation of breadth-first search, constructing a graph of where the possible cat moves are on a specific board, finding the best paths for the cat to take, code that handles drawing of the world and the drawing of the cat, 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 2htdp/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.
<test-infrastructure> <world-tests> <board->graph-tests> <breadth-first-search-tests> <cats-path-tests> <drawing-tests> <input-tests>
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 illustrations of the behavior of the function and so are included in the function’s description.