CS 117 Final Project
Due 5:00 PM Monday, 11/20/00


For your final project, you will write one of the programs described below. You will work alone for this project. This does not mean that you shouldn't talk with each other and lab assistants about your project. It does mean that the bulk of your code should be your own, and that any assistance you receive from others should be acknowledged in the comments and documentation accompanying your code.

If you have a project idea that does not fit the following categories, feel free to talk to me about it.

I: A Game

Write a game program. You can approach this with the goal of making the game fun to play, making the computer play well (even if it's not much fun for the user), or both.

Good games to implement include Bagels (see a previous final project description for details), Boggle, 3D Tic-Tac-Toe, Blackjack, Cribbage, Dots and Boxes, Battleship,....

Let me know ifyou have questions about the rules or suitability of a particular game.

You may use graphics to display your game, but that is not necessary.

II: Moveable Movies

If you choose to do this project, you will write a program that uses the g2 graphics library (here's an example graphics program ) to display a short movie. The content of your movie is up to you, but it need not be complicated.

There's a catch, though. Your code must be organized so that the movie can be shown in a frame of any size or location. In particular, your code should include a function described as follows:


	//
	//	DrawFrame
	//
	//	Draws the Nth frame of the movie inside the rectangle
	//	the coordinates of whose top, bottom, and sides are
	//	given by the parameters top, right, bottom, and left.
	//	Note that no drawing is done outside this rectangle,
	//	and that no assumptions are made about the width, height,
	//	or ratio of width to height of the rectangle.
	//	
	
	void DrawFrame( int window, int N, int left, int top, int right, int bottom );

There are lots of cute tricks you can play with your movie if you organize the code in this way. For example, you could show the movie in two locations on the screen simultaneously by doing something like this:


	for( int i=0; i < nFrames; i++ )
	{
		DrawFrame( window, i, 0, 0, 200, 200 );
		DrawFrame( window, i, 300, 300, 500, 500 );
	}

Or you might show all the frames simultaneously in one window, lined up in a grid so you could compare all the frames at the same time. Or you could draw a fancy border, and show the movie inside it.

You need not do any of these things with your code, but you should definitely test it in rectangles of various shapes and positions.

NOTE: DrawFrame should not call g2_open_X11(). In fact, your main program should call g2_open_X11() once, after which g2_open_X11() should never be called again.

III: Monte Carlo Integration

This one is most likely to make sense to you if you've taken calculus.

Suppose you want to approximate the area under the graph of a function. You may have seen techniques like the trapezoidal rule or Simpson's rule, but there's another technique called "Monte Carlo Integration." Take, for example, the graph of f(x) = x^2 between x=0 and x=2. The graph fits inside the rectangle R = [0,2]x[0,4]. Now suppose you generate a few thousand random points in R. If you compute

# of points under the graph of f
___________________________________

total # of points 

and then multiply this ratio times 8 (the area of R), you'll get an approximation of the area under the graph of f.

For this project, write a program that will compute Monte Carlo approximations of integrals. Your program should present the user with a menu of three or four functions to choose from, and should ask the user to specify the rectangle R (your program does not have to figure out the y interval from a given x interval--that's a hard problem). The user should also be able to choose how many random points your program will generate. Once the user has ordered up an approximation, your program should do two things:

If this project strikes your fancy, then you'll definitely want to use sqrt(4-x^2) as one of your functions.

What to Hand In, When, and How?

Grading Criteria

That's all

If you have questions, please let me know.

Start early, stay in touch, and have fun.



Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057, (507) 646-4364, jondich@carleton.edu