Tip:
Highlight text to annotate it
X
Assuming we haven't already done so,
we download the zip file and unpack it.
We open the file for problem 1.
Note that the .mla and .hdb files for
the simulator library and its help are also in the directory.
The simulator works most easily if the file being worked on is in the same directory as the .mla and .hdb.
The file opens and we see a partially completed worksheet.
We're interested in the code edit region's contents.
It contains a restart (good for starting with a clean slate on runs or reruns)
a libname := ".", .... (to let Maple know it should look in same directory as the worksheet we opened for the CarSimulator.mla and .hdb files).
and several lines of code to initialize the arena and the simulator.
As well as a partially completed procedure run2a that we should fill in.
We're just highlighting the libname line here to explain how Maple finds the CarSimulator package.
This line adds "." to the list of places Maple looks for the package. "." is the standard shorthand for "the directory you're using".
We put in a few moves into the procedure to show what happens when we simulate that.
The move(1) operation will move the car forward one square when the procedure is run in the simulator.
There are a few extra instructions after the procedure that will print out some messages after the simulation is done.
The highlighted line is the operation that runs the procedure you created just above in the simulator. We just wanted to you to notice it.
To run the whole region, we can type command- e (control-e on Windows), or use the menu as we do here.
After a few seconds, the results appear below the code edit region -- some messages displaying results, plus an animation.
We scroll downwards and look at these results.
The messages say the car took two moves.
The state table indicates positions of the car and its state (normal mostly).
The animation should be after the message from the simulator that it stopped -- the second one after the code edit region in this situation.
We can play the animation by clicking on the play button, as we did in Lab 4 of CS 121.
We can modify the procedure (we're putting in a left turn here) and rerun things by editing and then re-executing the region.
Having the restart at the beginning of the region is important to make sure that things really start from the beginning again.
The re-execution indicates that the car did a few more moves and turns. The state table has an entry that just does the turn.