Assignment 22
Due Date Mon 4/10 at 11:59pm
Possible Points 30
Purpose To use new design skills to solve complex problems.
Graded Exercises
Matt has a favorite game. That game is, of course, Typaholic! He has a game he loves almost as much, however: Flood-It. Because it’s his second favorite game, he was very excited to assign it as a homework.
When he brought this up at staff meeting, however, the tutors claimed it was "insane" to ask students to code a full-fledged game in half a week. "Can we at least give them the data definitions?" they asked. "Fine, we can give them the data definitions," Matt begrudgingly complied.
"Well, if we’re going to give them the data definitions, we may as well give them the main function," the tutors suggested. "Yes, ok, we’ll give them the main function," Matt yielded.
"Well, if we’re going to give them the main function, we may as well give them the less interesting big-bang handlers," the tutors proposed. "Fine, we’ll give them everything except on-tick," Matt said, on the verge of tears.
"Well, if we’re going to give them everything except on-tick, we may as well give them everything except the code of the most interesting helper function for on-tick," the tutors recommended. "Fine, we’ll give them everything except the code of the most interesting helper function for on-tick," Matt sobbed, heartbroken that students wouldn’t implement his second favorite game from scratch.
Exercise 1 Implement the flooding-flood function in this program (right click > save as...) so that it passes the given tests and adheres to the purpose statement.
Heads up:
While your game should animate like the one linked above, it will likely not run quite as quickly. That is perfectly fine and is a result of how big-bang generates its images, which is obviously beyond your control.
If you click at the very edge of the screen, your game may crash because the click happened just past the edge of the tiles. That’s fine, just ignore it and play again. You are welcome to change around the mouse-event code to prevent this from happening if you want to, but that will not be graded.
The game linked above has a notion of winning and losing. No such things exist in our code because we are all winners (and also because Matt usually loses).
Hints:
Read the entire file. It is much easier to change code when you understand the context it’s in. This is also good practice for the next homework.
Make sure you understand the tests given for flooding-flood. You can use the draw function, where grid-size is 3, to think through these tests.
The test for still->flooding will give further context to these tests, and in a game this step would happen before flooding-flood. This test and using the draw function on its input/output should help clarify further (again, where grid-size is 3).
While you only have to implement one helper function, there’s a good chance that it will need its own helpers.