Assigned 29 Jan; due 9 Feb.
Download the WalkingBuggles folder from my download directory on panther. It should contain
For Version 1 of this homework, open the BishopBuggle.java file and change the tick() method so the Buggle "walks diagonally". For example, if it were facing east, at each tick() it would take one step east and one step north, ending up facing the same direction it started.
As you play with this BishopBuggle, you may wonder what it'll do if it walks into a corner. Before you try it, draw a picture of what you think it'll do (or what you hope it'll do). Try a couple of examples. It turns out that, since a BishopBuggle's path is two squares wide, there are two different ways for a Buggle to "walk into a corner":
For Version 3 of the program, make sure your BishopBuggle does both of these properly. Try my solution.
For Version 4 of the program, we'll change the way the WalkingBuggleWorld works, so that whenever we hit the "Run" button, it creates not one but two BishopBuggles at two random locations on the screen, and every time we hit the "Tick" button, both of them move. This shouldn't require any further changes to the BishopBuggle.java file, but you'll need to modify the WalkingBuggleWorld.java file (and perhaps look at, but not modify, the TickBuggleWorld.java file). To help keep the two buggles straight, make them different colors. Try my solution.
In Version 5, we'll generalize what we've done above to handle a number of BishopBuggles, stored in a Vector (see chapter 8 of the textbook). When the user hits the "Run" button, your program should create at least three BishopBuggles (for now, you may simply always create three, or always four, or you may use a Randomizer to decide how many to create), and store them in a Vector rather than giving them each its own name. Then when the user hits "Tick", all the BishopBuggles in the Vector will be sent a tick() message.
Try my solution. Note: I originally wrote this to create three Buggles, but one time I tried hitting "reset" and "run" again to get a more interesting set of initial positions, and found to my surprise that I now had six, all moving in lock-step: the original three hadn't gone away when I hit "reset" and "run", and they had now been joined by three more. Not what I had in mind, but an interesting result nonetheless.
Try my solution, which also sets the color of each new Buggle randomly. I'm still working on this one....