Teaching
211 F '07
 
Assignments
The Hand In
The Recipes
The World
Set 1
Set 2
Set 3
Set 4
Set 5
Set 6
Set 7
Set 8
Set 9
Set 10
Set X1

Problem Set 7

Due date: 10/24 @ 6pm

Programming Language: Begnning Student Language with List Abbreviations

Teachpacks: world.ss


The goal of this problem set is to study the design of a small game program. Designing this program will demonstrate how the design recipe scales up to a first interesting program.


The Problem:

Imagine you have become a game developer and your manager poses the problem of developing the first version of the Snake Game.

SNAKE is one of the early computer games that caught peoples' attention when it first came out.

The player is in control of a snake whose sole purpose in life is to eat food and to grow bigger. Initially the snake is just one segment long: the head. When it eats a pile of food, it grows by one segment.

The snake is always on the move (up, down, left, right). When the game starts, the snake is moving left. At every clock tick, the snake moves in its current direction by one segment. The player can change this direction by pressing one of the arrow keys. Naturally if the snake is already moving in the direction of the pressed key, nothing changes.

When the snake's head is close to the pile of food on the playing field, the snake eats the food and grows by one segment. That is, the food disappears, and the snake is extended by one segment at the tail end. After the food is eaten, a new pile of food appears at some other, random location on the playing field.

The goal of the game is to grow the snake as large as possible. The game stops if (1) the snake runs into itself or (2) the snake hit the wall.

Design and implement the game in a step-by-step, bottom-up fashion.

Grading: if you don't follow the design recipe all the way, you will inflict a lot of punishment on yourself, because you will spend a tremendous amount of time getting the game to work. In addition, the graders will punish you a lot. You must design your program in "Beginning Language with List Abbreviations."

You may find the code from Lecture 18 useful.


last updated on Mon Nov 19 01:21:50 EST 2007generated with PLT Scheme