Intro. to Comp. Sci (year) - 1

Fall 2018 -- Peter Brooks

Cribsheets that you'll get during the final, and advice Netlogo, Racket
Advice from the wise Mr. Brown-Mykolyk
Practice finals from yesteryear Fall 2011 (Netlogo part)
Fall 2016

I am not in today (Tues).  Look around to verify this.  You should ALL work on answering the practice-finals questions.  Look through them, and figure out the ones that you expect to have difficulty with.  Work on those, and I'll be answering questions on Wed.
The Info Tab requirements


Here are two demonstration programs that might be useful in your projects.
The 2 Netlogo tests (#2 and #2.5) Here is the test that I gave last Friday.  Here is the model with all of the answers.
Here is the second test I gave.  Here is the model with all of the answers.
Intro to State Variables programming Here and here are a couple of examples of state variables in use.
Here is a classroom project to duplicate.
Project proposals due, Fri, 12/21 8:00am Your project proposal should be submitted to the homework server, either typed into the Comments-to-Teacher, or uploaded as a .doc, .docx or .pdf file.
1. If you're proposing to make a game: tell me what the user will see, what she will want to accomplish, what kinds of controls she has, and what makes her task difficult.  Will there be levels of diffuculty?  Score kept?  Score kept between games?
2. If you're proposing to create a simulation, what is it about?  What will the user be able to control?  What will the user learn? ( It needs to be about the real or mathematical world.)
3. If you want to do an animation, see me about it.
Using min-one-of demo here.
Trigger technique. Here is the model (Techniques-gun.nlogo) shown in class, that allows you to "fire" only once when the mouse button is pressed.
Sick today. OK, you've looked at the Code-Examples and seen some cool ones.  The time has come to learn how the effects are created.  Choose one or two of the code examples that intrigue you, and try to understand the code.  Create a similar model yourself to see if you can do it.
Breeds and Arguments and Reporters, Oh My
Homework, due Mon, 12/10 midnight
Here's a demo.  Download and run the model, and read the explanations in the Info tab.

Here's a model (TicTacToe) that you should duplicate Note: you CAN turn world-wrapping off using the Settings button, but you have to change the number of patches and the patch size in the Setup procedure.
Wed, Dec. 5

Quick classwork/homework task with a homework slot,
due Wed midnight (Thurs morning 8:00a)
Look around -- if you can see me, you're hallucinating (or I'd really like to know what you're doing in my kitchen).

One of the most interesting portions of the Netlogo documentation is the section in the Models Library called "Code Examples".  I want you to spend this period trying various examples from this list.  These examples are typically quite small models intended to show off and teach how to use some feature of Netlogo, or some programming technique to achieve an effect.  There are some very cool ones, as well as important ones showing how to do things.

So go sample.  Just don't try the sound extension in class (do this at home if interested).
Find a favorite one, and write a short paragraph into the Comments-to-Teacher on why this example intrigued you and whether you learned how to do what it was teaching (best bet: open another Netlogo model and try the technique!).  You can finish this in class or continue at home.
Cellular Automata Here are some very simple Game-of-Life structures.
Here's Golly, available for downloading.
More painting and image processing Download this model.  Duplicate this model by tonight (or 8:00am Wed. 11/28)
Animation contest!  Entries due Sun, 11/25, midnight 1. Create an animation that will hold the viewer's interest (pleasantly) for its duration.
2. There should be, at most, two buttons (Setup & Go) or just Go; no other viewer interactions.
3. If for some reason your entry consists of more than one file (the .nlogo file), create a .ZIP file from all your entry files, and submit that.
4. Preferably less than 3 minutes long.
5. This is a mandatory homework assignment.  It will be graded and worth the equivalent of a quiz.
6. However, you can choose whether or not to allow your entry to be shown to the class (most good entries will be shown).  If you do not want it shown, then write "Don't show" in the Comments-to-Teacher when submitting your entry.  If you don't write anything, then by default, I might show it.
7. First place winner will get an additional 2 grade points on the final course grade.  Second place: 1 additional grade point.
8. Judgements by the class autocrat are final.
9. Your entry should be shown to your parents.
Image Processing Here are a couple of pictures that you can right-click on and download: car.jpg and duckCat.jpg, apartment.jpg, apartment2.jpg , as a small image-processing program: ImageProc3.nlogo.
Also, here is my PatchPainter.nlogo program.
NetLogo homework #5,due Thurs, 11/15, midnight You'll be develloping an interactions model similar to the one we worked on in class.  Duplicate this model.
Netlogo homework #4, due Tues, 11/6 midnight You should duplicate this model. And here are some ideas that will be useful in constructing this model.  Here's some information about this model:

In the 1st exercise, with Setup1 and Go1, create 50 turtles, and move them around drunkenly, with a step size of 0.1, and an "every" timer interval of 0.05.  The Birth and Death sliders provide the percentage chance that a turtle will either "hatch 1 [fd 1]"  or "die".  So, if the death percentage is set to 6, for instance, then there should be a 6% chance, on each step, that that turtle will die.  Notice what happens to the different colored groups of turtles -- they start out with 50 different colors, but over time...  This might explain the possibility (actually, high probability) that we are all descendents of a single female -- her progenie would have, by chance over a long time, be the only ones who survived.

In the 2nd exercise, we have a similar model.  This time the Setup2 button will also create 50 turtles, and then turn "percent-red" of the patches red.  The Go2 will move the turtles around drunkenly with the same step size of 0.1, and an "every" timer interval of 0.05.  If a turtle is not on a red patch, then it just takes a normal drunken step.  However, if it steps on a red patch, there's a 50% chance it'll die, and a 50% chance that it will move forward 1, and then hatch a daughter.

In the 3rd exercise: we'll be letting a turtle color the patches that it steps on.  Create a single turtle of size 1.5 and color green.  The turtle should move drunkenly with a step size of 1, every 0.05 seconds.  The turtle will always recolor the patch it steps on, in the following order: if the patch is black, paint it red, if already red, paint it blue, if already blue, then yellow, and finally, if yellow then back to black.  Also create a monitor that will report the percentage of the patches that are yellow.  The monitor can calculate that using the expression:  "100 * count patches with [pcolor = yellow] / count patches".  If everything works well, the world eventually should have approximately one quarter of each colored patches.
Animation! Here are a couple of tiny demos to show techniques of animation in the service of a little story-telling.  To download these demos, right-click on the link and choose "Save link as.."
Mr. Brooks's Laws of Netlogo Design/Style  
Thurs, 11/1: If you look around, you may notice that I'm not there today. Today's a perfect day to do the homework for tonight.  Remember: you must come up with at least two new ideas from researching the Netlogo documentation (that you get to from the Help menu item on the Netlogo screen).  You must incorporate and/or highlight the use of those ideas in a Netlogo model, create an adequate Info tab that will explain their use in your model.  You must also name those two or more ideas in the Comments-to-Teacher, also in the same homework slot, at the same time that you're submitting your Netlogo file.
Netlogo homework #3, due Thurs, 11/1, midnight Find two new ideas/constructs (haven't been covered in class) in Netlogo and make use of them in a new model to show off those new items.  These new ideas SHOULD NOT come from either the Netlogo cribsheet or the Netlogo videos.  Insetad, use Netlogo's documentation as your source.  Document your use of all of the new ideas/constructs in the Info tab of the model, and upload the model to the homework server.  Also, put a very short description of new things into the Comments-to-Teacher. 
Netlogo homework #2, due Wed, 10/24, midnight Create a model that looks and behaves like this  -- right-click and choose "Save as..." to download this .nlogo file to your computer, and remember where you saved it.  Then launch Netlogo and use its File/Open menu item to retrieve this downloaded file.
Absent today (Wed, 10/17) Note: you can retrieve your submitted homework programs using the "View Homework" tab on the homework server.  If you have not successfully done one or more of the homework problems (including the challenge ones), find a a neighbor who has, and learn how he/she did it.  Then try it yourself.
Netlogo homework #1, due: Tues, 10/16 midnight You're going to be drawing pictures with your turtles.  Some easy, some hard.  I'm not giving you exact dimensions of the figures you need to replicate -- instead I'm asking you to approximate the look by a process of trying and fixing if necessary.  Remember: when I press a button to display one of the figures, what's shown is all I want to see (for instance, I don't want to see your turtles).  Save your .nlogo file and submit it to the homework server.
NetLogo videos! If you want to sail ahead in NetLogo, or if you want to review NetLogo concepts before a test, or if you just can't get enough of Mr. Brooks's somnolescent (look it up) voice, here are my NetLogo videos.
The NetLogo Cribsheet You'll eventually learn all of the NetLogo constructs on this cribsheet and will need to know how to use them.  However, you'll be given a copy of this cribsheet during every NetLogo quiz or test, so this is not an exercise in memorization.
Netlogo! Download NetLogo from its site.  Just like DrRacket, you'll need to know whether your operating system is 32-bit or 64-bit.  To find out on Windows, go to your Control Panel and then choose "System" for information about your Operating System.  Install NetLogo and run it at least once to make sure it's healthy.
Second Scheme homework, due Tues 10/2, midnight  
Scheme information The Scheme cribsheet
SchemingBat practice site
First Scheme/Racket homework, due Mon,9/24 midnight  
Getting DrRacket after it's been introduced in class. 1. Download it: You can download the DrRacket program here:  You will be asked whether your operating-system is 32-bit or 64-bit.  If you are using some version of Windows, you can find the answer by going to the Control Panel (where the operating system settings are), and looking at the "System" panel.  If you cannot find the answer, then choose the 32-bit version of the downloader.  If you have a Mac, you might Google: "Is mac os x 32 or 64 bit?" to try to find the answer.
2a. Install it: run the downloader program.
2b. If it doesn't work, try it once more (after trying to remove the program that failed).  If it still doesn't work, try to remember what the installation was doing just before the failure, and what the error message was.  Bring that information to class so that we can help overcome the problem.
3. Run it: An icon (an image of the Greek lambda character) should have been created for you upon installation -- that's how to start the DrRacket program.  Start it up, and remember to choose the "R5RS" language (and right after choosing the language, press the RUN button at the top) like we did in class.
Computer jargon quiz, Thurs short answers
Computer jargon list You should know these terms.
Rules of the game Read How to Comp Sci at Stuy
First task: fill out your Profile on the Homework server.
  1. Go to the main class link page (
  2. Click on the Homework/Grade server link
  3. Choose the Profile menu item
  4. Choose your period and name
  5. Log in with your OSIS number as your password
  6. Fill out your email address and preferred first name only, DO NOT CHANGE YOUR PASSWORD YET.
  7. Save: (Change Profile button)...
  8. (optional, but recommended): now you can change your password for this Homework server, if you want.
  9. REMEMBER this password!
Help from Mr. Brooks Feel free to come and see me during periods 6, 7, or 8 in room 301 (just walk in) or by appointment beforehand just after school also in room 301.
Sending email to Mr. Brooks:
Send mail to:

You MUST include your name in the subject line or body of the message, otherwise I won't know who it's from.
Stuyvesant bell schedule  
Homework/grade server  
Support Wikipedia