NOTE: This assignment, like others in this class, is due at the beginning of the class period. This means that if you are even a minute late, you lose 20%. If you are worried about potentially being late, turn in your homework ahead of time. Do this by submitting them to me during office hours or by sliding it under my office door. Do not send assignments to me through email or leave them in my departmental mail box.
While the textbook for this course is excellent in some respects, there are also some flaws. One flaw is that the code given sometimes doesn't match the text that describes it. We'll treat this bug as a feature, however, and make homework assignments out of correcting the textbook.
Examine the code in Chapter 3 of the textbook (this is variously described as C code and pseudo-code) and read the accompanying text.
Note that the mistakes describing the code begin with the very first example. On page 78, the text claims that, for the code shown there, "Each execution through the loop would cause the agent to move for one second, then the loop would repeat." This is in conflict with the latter statement on that same page that "[i]f the agent does not sense the releaser for the behavior, the agent does nothing." Most likely what is meant is that if the predator is sensed, then the agent will flee for one second, otherwise the agent will not move on that pass through the loop, after which the loop will repeat.
Okay, I've corrected the first mistake and I hope you get the idea of how to carefully read the text and examine the code to find and correct problems. Now it is your turn.
Examine the code that starts on page 79 and carries over onto page 80.
Examine the code that starts on page 81 and carries over onto page 82.
Turn in a typed copy of your answers to these questions. In total, your answers should run from 1.5 to 2 pages in length (roughly 80 characters per line, 50 lines per page).