CMSC 15100 Autumn 2019: Homework 0

Homework 0 is an ungraded exercise intended to get you up to speed with the basics of git and DrRacket. The purpose of the work is to gain experience and set up your machine, and we will use the same workflow for the rest of this quarter.

These instructions are intended to be followed on your own machine, to set it up to match the installations and configurations that are present in CSIL.

In order to manage exchange of work between you and the instructional staff, we will make use of git, which is a popular open-source revision control system for software development. (Other popular tools in this category include subversion and mercurial.)

The first action you should take today is to check out your git repository. Checking out a repository creates a local copy of it on the computer on which you are currently working. You can check out a git repository on any computer; you will want to check out your repository on any of your own computers, to be sure. You only need to check out a repository at the rate of once per computer, since once a repository is checked out on a particular computer, it need not be checked out any further. Having said that, if you come to a computer where you think your repository has been checked out, but you can't locate it, you can check it out again to re-establish it there. (This will be needed in the CSIL Mac labs in particular, since the computers are erased and recreated from scratch every 24 hours. In contrast, the CSIL Linux labs are networked such that you need only check out your repository once on any of the Linux computers, and then it will be available across all of them.)

The name of your git repository is simply your CNetID (i.e., your email address), and the repository is accessed through a URL that contains the course information. We will place the repository within a folder on the desktop of your computer; the instructions for how to do this vary depending upon the type of computer you are using.

macOS: In the Finder, from the Go menu, choose Utilities. Then open Terminal. To check out a local copy of your repository in a folder on the Desktop, enter the following commands into the terminal window, one line at a time, pressing return after each:

cd Desktop
mkdir cs151-aut-19
cd cs151-aut-19
git clone https://mit.cs.uchicago.edu/cmsc15100-aut-19/CNET.git
      
You will have to enter your CNetID and password after the git step. Before you do so, macOS may pop up a dialog asking you to install command-line tools; if so, agree to do so. If it asks for a password in a dialog box, this is the password for your account on your computer, not your CNetID password. After having completed all these steps, you should see a directory (folder) on your Desktop with the name cs151-aut-19, and within it should be a folder with your own username; this is your local copy. Leave the terminal window open; we'll continue to use it later. If you experience any errors, see below.

Windows: Install cygwin. Make sure you select git during the installation process; this is an optional part of the installation. Once installed, launch cygwin; you should have a terminal window. To check out a local copy of your repository on the Desktop, enter the following commands into the terminal window, one line at a time, pressing return after each. Replace accountname with the username for the account on your computer.

cd /cygdrive/c/Users/accountname/Desktop
mkdir cs151-aut-19
cd cs151-aut-19
git clone https://mit.cs.uchicago.edu/cmsc15100-aut-19/CNET.git
      
You will have to enter your CNetID and password after the git step. After having completed all these steps, you should see a directory (folder) on your Desktop with the name cs151-aut-19, and within it should be a folder with your own username; this is your local copy. Leave the terminal window open; we'll continue to use it later. If you experience any errors, see below.

All systems, continue from here. If you were unable to check out your repository, it may have been that a) you mistyped the command, b) you literally typed CNET instead of your own personal cnet ID, or c) you may not yet have a repository because you very recently added the course. If you are in group c, just create a directory on the Desktop named "repo" and continue through the exercise (but note that you cannot perform any of the git-related steps listed later until your real repository exists). If you do not have a real repository yet, download these two files: cs151-core.rkt and cs151-image.rkt and save them within your repo folder, within a subdirectory named include.

Once you have a either a local copy of your repository or a simulated repository "repo", please create a directory inside of it named "hw0". Be sure that this directory name is exactly as shown, with no capital letters. The hw0 directory is where you will complete this exercise.

Next, install DrRacket.

Launch DrRacket. Then, go to the File menu, choose Install Package, and then enter 2htdp-typed in the text box.

You should also start a DrRacket file that specifies the programming language and includes two support files in include. This racket file should be saved under the name hw0.rkt in the hw0 directory in your repository. Initially, its contents should be exactly this:

#lang typed/racket
(require "../include/cs151-core.rkt")
(require "../include/cs151-image.rkt")
      
You should be able to run this code by clicking the Run button at top right; if anything goes wrong at this stage, you should try to track it down and correct it. As you continue to write more code, click the same Run button to run the code and evaluate your progress.

Once you have these directories and files set up, from the command line:

cd CNET
git add hw0/hw0.rkt
git commit -m "starting hw0"
git push
      

The first command navigates into your repository. The second command tells git to prepare to send the hw0.rkt file in the "hw0" directory to the server. The third command makes this into a "commit" ( a group of changes to be synced with the server), with a corresponding explanation for what work has been completed. The final command actually sends everything to the server.

These instructions should result in a file getting copied across the network, and you will see some text at the console so indicating.

As a rule of thumb, you must add and commit your work in order to submit it. You cannot add but not commit, nor can you commit without adding. You must take both steps, and the add step must happen before the commit step. You should also know that adding an item unnecessarily, one or more additional times, is totally harmless, so if you have any doubt about whether a file has been added or not, go ahead and add it again without fear. Note also that after adding and committing, you should always push, or else your work is not sent to the server.

All these logistics have been to set up your computer so that you can work; now you can move on to today's programming exercise. Your task is to use the image library to draw an image of at least three recognizable animals posed next to or near each other. It is perfectly fine for the depiction to be cartoonish and simplified; that's what we're expecting. You will build it out of the primitive shapes that are available in the image library: squares, rectangles, circles, triangles, and so on. Documentation for the image library, including many visual examples, is here:

https://docs.racket-lang.org/teachpack/2htdpimage.html?q=2htdp%20image

Images can be put beside and above one another; they can also be superimposed with overlay. Keep in mind these operators are not limited to two arguments; you can supply many arguments to them, as in (above a b c d). You can align two side-by-side images at bottom with (beside/align "bottom" i j); you could use "top" in place of "bottom" as well, with the intended effect. You can also use above/align with "left" or "right". There are many other tools available for image construction as well, including rotation and scaling; the online documents give full details. Please explore and see what you discover.

The named colors understood by this library are the set of web named colors documented here (and many other places).

As far as the style of your code goes, please be mindful of the following: your code should not exceed 80 characters wide; you should use DrRacket's tab key to manage indentation; you should name common items with define to avoid redundancy. For example, if your picture involves drawing trees, you might include this definition in your code:

(: tree Image)
(define tree (above (triangle 12 "solid" "green")
                    (rectangle 4 8 "solid" "brown")))
      
After having done that, you could refer to tree by name any number of times in the code that follows.

Make sure to commit your latest version of hw0.rkt to your repository by noon on Thursday; we will provide you with confirmation that the submission was received afterwards. Please note: this is an ungraded assignment. If you are participating in religious observances this week or are otherwise unable to make this deadline, you will not be penalized. Nonetheless, please try to complete this work to ensure your computer is appropriately configured for the course.

Any time you want to send a copy of your work to the server, open a terminal window. Then, navigate to your repository:

and then, on all systems:
git add hw0/hw0.rkt
git commit -m "message explaining what has changed since last commit"
git push
      
Any time you begin work on a different computer after having made progress on another computer, you should sync the updates that have been sent to the server from the prior computer. Do this by issuing the same first command, the one beginning with cd that depends upon the type of system being used. Then, execute git pull to ask the server for the latest updates.