1.18.1 Overview

► |  | Games: Fun Examples

1 | Bundled Games
2 | Implementing New Games
3 | Showing Scribbled Help
4 | Showing Text Help

► | 1 | Bundled Games

1.1 | Aces — Solitaire Card Game
1.2 | Go Fish — Kid’s Card Game
1.3 | Crazy 8s — Card Game
1.4 | Blackjack — 21 Card Game
1.5 | Rummy — Card Game
1.6 | Spider — Solitaire Card Game
1.7 | Memory — Kid’s Game
1.8 | Slidey — Picture Puzzle
1.9 | Same — Dot-Removing Game
1.10 | Minesweeper — Logic Game
1.11 | Paint By Numbers — Logic Game
1.12 | Lights Out — Logic Game
1.13 | Pousse — Tic-Tac-Toe-like Game
1.14 | Gobblet — Strategy Game
1.15 | Jewel — 3-D Skill Game
1.16 | Parcheesi — Board Game
1.17 | Checkers — Board Game
1.18 | Chat Noir — Puzzle Game
1.19 | Tally Maze — Maze Enumeration Game
1.20 | GCalc — Visual λ-Calculus

▼ | 1.18 | Chat Noir — Puzzle Game

1.18.1 | Overview
1.18.2 | The World
1.18.3 | Breadth-first Search
1.18.4 | Board to Graph
1.18.5 | The Cat’s Path
1.18.6 | Drawing the Cat
1.18.7 | Drawing the World
1.18.8 | Handling Input
1.18.9 | Tests
1.18.10 | Run, program, run

On this page:

<main>
<tests>

Racket
top contents ← prev up next →

#### 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.

<main> ::=

> (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.

<tests> ::=

> <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.

top contents ← prev up next →