1.18  Chat Noir Puzzle Game

The goal of Chat Noir 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 start a new game, hit the “n” key (but only after losing or winning a game).

To play Chat Noir, run the PLT Games program. (Under Unix, it’s called plt-games).

To get some insight into the cat’s behavior, press 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. Note that this slows down the game considerably, so you can turn it back off by pressing “h” again.

The game was inspired by the one at 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.

The remainder of this document explains the implementation of the Chat Noir game in a Literate Programming style.

    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