Homework 1 (S1 2018)
This is the first homework assignment. Your goal in this assignment is to read and understand a simple program, and modify it so that it works. Along the way, it is also important that you get familiar with the python programming environment, and take your first step towards learning how to use it effectively.
Practical information#
The assignment is due on Monday the 5th of March, at 9am. To submit your solution, you will upload a single python file via wattle. Here is the assignment submission link.
In addition to submitting your solution, you must attend the following lab (in week 3). In the lab, your tutor will ask you some questions about your solution, and give you feedback if there is anything you need to improve. This discussion with the tutor is also part of the assessment. If you do not show up for the discussion with the tutor, you will not receive any marks for this assignment. If you do not submit a solution, you may still get some marks following the discussion with the tutor.
The assignment can be done together in pairs, but not in a group of more than two students. You may also do the assignment on your own if you prefer.
If you work in a pair, both students must submit solution files, and both students must attend the following lab and answer the tutors questions. In your solution file, write a comment (using python comment syntax) to say who you worked together with - you should write their ANU id. Both of you must be able to explain every part of your submitted solution. The tutor will choose who to address each question to, and only the student addressed may answer. It is not acceptable to divide the assignment up so that one student does half and the other student the other half.
If you have followed the lectures and worked through the exercises in lab 1, the assignment should not take more than one or two hours to complete. There will also be a survey on wattle, asking you some questions about the assignment (for example, how long you spent on it). The survey is not part of the assessment.
The problem#
This assignment problem uses the robot simulator that was also used in lab 1. First, you must download these two files:
Save both files to the same directory.
The problem is how to unstack a tower of blocks. That is, to go from this:
to this:
unstack.py
contains several functions that implement a solution to
this problem. Because the robot (at least in simulation) can carry more
than one block, the idea of the solution is that we will first unstack
the top two blocks from the third, put down this stack of two, and then
solve the smaller problem of unstacking the top block from the stack of
two using the same manouvre.
However, the implementation of this solution has some errors. Your task
is to correct the errors.
unstack.py
also contains two test functions, called test_unstack_two()
and test_unstack_three()
. The first tests the simpler case of unstacking
just two blocks, while the second tests unstacking of a tower of three.
Because the file contains only function definitions, you will not see anything happen when you run it. To run the test functions, you must first run the file and then call the function, for example
>>> test_unstack_two()
(Remember that if you run the python interpreter from a terminal, you
have to use the -i
flag to leave the shell in interactive mode after
running the file.)
The first error you will encounter is a NameError
. As mentioned in
the lecture, this means there is a mismatch between the name of a
function’s definition and use. Use the information from the python
error message to track down where the error is.
Once you have resolved this error, the test_unstack_two()
function
should work. In the solution for unstacking three blocks there is a
logical error that may require more thought to fix. However, it does
not require a big change to the functions. You should not write an
entirely new solution to the problem. Focus on understanding how the
given solution is intended to work, and what changes are needed to
make it work. (It may be as simple as changing one line.)
Marking#
Upload the unstack.py
file with your corrections.
The file that you submit must meet certain requirements. It must be
syntatically correct python code, and, like the one you downloaded,
must contain only function definitions, the import
statement, and comments.
It must contain the two functions test_unstack_two()
and
test_unstack_three()
, and these functions should not have been modified.
As mentioned above, you must also attend the following lab (in week 3) and answer your tutor’s questions about your solution. This discussion is part of the assessment. You should be prepared to answer or demonstrate the following:
- Can you download the file that you submitted from wattle?
- Can you run that file in the python interpreter (using an IDE of your choice) on the CSIT lab computer?
- If the file has syntax errors, can you use the error messages from the interpreter or IDE to identify where the syntax errors are?
- Does your submitted file meet the requirements stated above? Does
it contain anything that is not a function definition, an
import
statement, or a comment? If so, can you point it out? - What was the cause of the
NameError
in the original file, and how did you fix it? - How did you fix the logical error in the
unstack_tower_of_three
function? Was this the smallest change necessary to fix the error? Could it have been done with a smaller change? - Can the solution to the unstacking problem be made more efficient, that is, with fewer moves of the robot or gripper?
- The original file had comments describing the each function, and the assumptions about the state of the robot when the function is called. Are these comments still accurate in your fixed version? Have you modified the comments so that they correctly describe the functions that you modifed?
The marking scale for this assignment is as follows:
- The submitted file is syntactically correct and meets the requirements: 0.5 marks.
- The first test case (
test_unstack_two
) works: 0.5 marks. Note that “works” means the code runs and does the right thing. If your code is not runable (has syntax errors), then it does not “work”. - The second test case (
test_unstack_three
) works: 0.5 marks. - Your ability to use the tools (e.g., the IDE or python interpreter), your understanding of python’s error messages, and your understanding of the solution, as demonstrated in your discussion with the tutor: up to 0.5 marks.
The assignment is worth 2% of your final mark.