Guess how the game works
1. Objectives
Completing all tasks in this assignment will help
you:
First skim, then carefully
read the entire assignment before
starting any tasks.
2. Guessing Game
We will
write a number-guessing game that has the same (or better behavior) as game.p, a file we have supplied for you. The game.p
file is a p-coded file; it is an executable MATLAB program created from the
file game.m. To play the program, copy game.p
into the working directory of MATLAB and enter game at the prompt.
Play with the program and get a feel for how it works.
You will eventually write an M-file called mygame.m
that will mimic the behavior of game.p,
but we will work our way there through intermediate stages.
Part
A:
Find the p-coded file game1.p on the course Web site,
and copy it into your working directory.
Enter game1 at the prompt and play it. When you understand how it works, write a
program called mygame1.p that behaves the same way.
Save your file as mygame1.m.
Part
B:
Now find the file game2.p. Follow the same instructions as in Part A.
Use your answer from Part A to write another program called mygame2.p
that imitates game2.p.
Save this file as mygame2.m.
Part
C:
Follow the same instructions as for Parts A and B, but for the file game3.p.
You should be able to use the results from Part B to complete this
portion.
Save the file as mygame3.m.
Part D:
Now see if you can write the full-blown
version of game.p.
Save your last file as mygame.m.
3. Submitting Your Work
Type your
name (and your partner’s name if you have one), student ID, and the date at the
top of each M-file. Print each file and sign them along with
your partner. Give the signed documents
to the teaching assistant at the end of the lab session.