# 1.18.10 Run, program, run

► |  | 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 | 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:

<initial-world>
<go>

top ← prev up next →

##### 1.18.10`` Run, program, run

This section contains expressions that start the Chat Noir game going.

First, here is a function to compute state of the world at the start of a game.

<initial-world> ::=

> ( define board-size 11)
> ( define (make-initial-world)
> ( define initial-board
> (add-n-random-blocked-cells
> 6
> (empty-board board-size)
> board-size))
> (make-world initial-board
> ( make-posn ( quotient board-size 2)
> ( quotient board-size 2))
> 'playing
> board-size
> #f
> #f))

Finally, we can define and provide a function to start the game by calling big-bang with the appropriate arguments.

<go> ::=

> ( provide main)
> ( define (main)
> ( void
> ( big-bang (make-initial-world)
> ( on-draw render-world
> (world-width board-size)
> (world-height board-size))
> ( on-key change)
> ( on-release release)
> ( on-mouse clack)
> (name "Chat Noir"))))

top ← prev up next →