home—info—lectures—exams—archive
hw03
Scheme project
Due 2008.Sep.26 (Fri) in class.
Turn in: a hard-copy of your programs,
as well as an electronic copy of a single file
(suffix “.ss”) on Blackboard(WebCT).
Update Sep.22 (Mon):
By popular demand1,
you'll turn in the entire homework Sep.29 (Mon), but
the following is due Friday.
Note that each bullet is at most 6-7 lines (including comments),
and most are only 2-4 lines.
With examples of the data and test cases, at least one (if not two)
examples should be a simple as possible.
- a data definition for a fire (including a struct, if needed),
and three examples of the data.
- a data definition for a list-of-fire,
and three examples.
- A function grow-fire : (-> fire fire),
which returns the fire one “tick” later
(assuming no water is falls on it during that tick).2
Include one test case (written before you write the code), and code.
- A function grow-fires : (-> (list-of fire) (list-of fire)).
Include three test cases (written before you write the code),
and code.
- A function draw-fire : (-> fire scene scene).
(No test cases required, since it's hard to manufacture the result-images
before you write your code.)
- A function draw-fires : (-> (list-of fire) scene scene).
(No test cases required, since it's hard to manufacture the result-images
before you write your code.)
In addition, I recommend by Friday:
- A world struct containing an airplane,
but no fires or water;
-
three examples of the data (of a world),
-
two test-cases for update-world and two test-cases for
process-keys,
-
The code draw-world and update-world
and process-keys as described.
(Of course, your world only has an airplane in it at the moment,
and nothing else.)
(If you do this much, you should be able to fly your plane.)
See WebCT/Blackboard, for hw03a-soln.ss.
See scheme-resources—ITEC380 Scheme resources
for reading links,
and information on running scheme.
- Complete the
the fire-fighting-game.
If you wonder exactly which symbols your function process-keys
might be given, you can see the
key-event documentation
(in the world teachpack).
(Note that this leads you to discover a function for comparing two keys
which is better than either char=? or symbol=?,
but won't ignore bad inputs like eq? or equal? do.)
If you want to modify your airplane struct/functions from
hw02, you can (but it's not necessary).
-
After you get the game working,
modify it so that water-droplets which are “below the ground”
are removed.
-
For fun:
If you (require scheme/gui/base),
you can then use play-sound.
-
Generalize insert-sort to take
two arguments, the second being a comparison function.
-
Extra credit: read about opt-lambda3.
Then, modify your insert-sort to take
either one or two inputs.
Points are only given for well-designed code
(don't repeat code unnecessarily!)
-
Programming Exercise 15.8 (subst-in-tree).
Note that this is (slightly) easier than the file/folder example
to be covered in lecture.
Extension allowed:
We did barely talk about mutual-recursion at the end of Friday
(the descendent-tree program).
This exercise is the same idea, though you need to interpret the
book to get the data definition.
If you want to turn this problem in with the next homework,
that's acceptable.
1Well, actually,
at Adam's demand. But I'll posit Adam is popular :-) ↩
2
Technically, since we don't update objects/structs:
it returns a new fire which is similar to the one passed in.
↩
3You
will need to
(require (lib "plt-pretty-big.ss" "lang"))
in order to use opt-lambda from the Advanced-student language.
↩
home—info—lectures—exams—archive