welcome to cs 5 ! introduction to cs an advocate of concrete computing when the course was over, i...

71
Welcome to CS 5 ! Introduction to CS an advocate of concrete computing When the course was over, I knew it was a good thing. We don't have strong enough words to describe this class. - New York Times Review of Courses - US News and Course Report We give this course two thumbs! - Ebert and Roeper 3 handouts… slides - syllabus - honesty policy

Upload: amanda-clark

Post on 26-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Welcome to CS 5 !

Introduction to CS

an advocate of concrete computing

When the course was over, I knew it was a good thing.

We don't have strong enough words to describe this class.

- New York Times Review of Courses

- US News and Course Report

We give this course two thumbs!- Ebert and Roeper

3 handouts…slides - syllabus - honesty policy

About us…

Chris StoneZach Dodds

[email protected] [email protected]

Olin 1251OfficeOlin 1255

Email

fan of low-tech games Slovenia?!

fan of low-level AIalternating in CS5

Scotland!?

Take-home message…

http://www.cs.hmc.edu/twiki/bin/view/CS5/

depending on where "home" is, perhaps…

Links to EVERYTHING!

CS 5 Sections

About Gold and Black sections…

• Everyone has been placed based only on past experience, not ability. Gold is for students new to CS, Black for students with previous CS experience, such as the AP.

• Most CS majors enter CS 5 without previous experience

• Tradeoff: more careful coverage vs. a few more applications

• Both Gold and Black sections will prepare you well for

• CS 60• Future computational work• A happy and fulfilling life :-)

official alien of the CS 5 Gold section

official mascot of the CS 5 Black section

• and the Green section is officially Bio/CS 6

Switch?

Today in CS 5

What is CS?

How does CS 5 run?

A little bit about Python…

What will the course cover?

This week's homeworkThis week's homework is a-MAZE-ing!

HELP!

1. In a sentence or so, what is computer science? Or, what are some major aspects of CS?

2. Try to describe one thing that you think that a researcher in computer science might study.

What is CS?"Quiz"

CS? Hmmm…

Name:

Credit Suisse?

Counter-Strike

C10H5ClN2 : CS gas

CompuServe

Computer Science

Cultural Survival

Extra moment? Read over the honesty policy & hand it in, too…

CS != programming

programming : CS ::

programming : CS ::

"not equal to"

CS != programming

programming : CS ::

machining : engineering

unicycles : HMC

grammar : literature

equations : mathematics

a vehicle, not a destination

Programming

CS

CS != programming

CS == complexity science

Study of complexity

How can it be done?

How well can it be done?

Can it be done at all?

What's it ?

"equal to"

CS == complexity science

Study of complexity

How can it be done?

How well can it be done?

Can it be done at all?

What's it ?

Information

Information

Study of complexity

How can it be done?

How well can it be done?

Can it be done at all?

"Make3d"What information is being transformed here?

What Google thinks we look like

"Chris Stone""Zach Dodds"

First Google Image hit (8/30/09) for a search of

What Google thinks we look like

"Chris Stone""Zach Dodds"

First Google Image hit (8/30/09) for a search of

Images are difficult!

What Google thinks we look like

"Chris Stone""Zach Dodds"

Images are difficult!

First Google Image hit (8/30/09) for a search of

Information

Study of complexity

How can it be done?

How well can it be done?

Can it be done at all?

The N-body problem: lots of interactions!

What information is being tracked here?

Hubble photo: galaxies colliding

Protein folding!

HW problem 0: Reading & Research

about CS's future…

HW problem 0: Reading & Research

about your future!?

4:15 pm this Thursday: Convocation (here)

5:30 pm this Th., 9/3/09: Summer Research Posters @ LAC

Writeups: Brief, thoughtful responses… hw0pr0.txt

Why CS ?

Information is life’s fundamental building block.

CS is a set of fundamental techniques for understanding and leveraging this information…

Genetic Code: DNA Our senses and experiences

GTAGCACAITTAGC… More coffee required…

us

“constructing with”

Whatever you are, be a good

one.- Abraham Lincoln

… CS will help!

Whatever you are, be a good

one.- Abraham Lincoln

Why CS 5 ?

A broad look across computer science

1

2

3 45

recursionsimulation

design

What is programming ?

Baggage !

Programming as recipe-writing

vs.

Programming as learning a foreign language1) Expect it to be different!2) Don’t feel you need to memorize it3) Immersion == Experimentation

The foreign language of python…

Homework 0, problem 1

hw0pr1.py

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Zach': # is it Zach? print 'Sorry - I\'m "offline." Try later.'

elif name == 'Chris': # is it Chris? print "But you're in Slovenia!" else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

Python and IDLE: Use them at home!

Editor window: code

Shell window: running code

Here, you can try things out at the

command prompt >>>

Here, you can save and change programs.

Hitting F5 runs your program over in the

shell

The foreign language of python…

syntax? semantics?

intent?How it looks

What it does

What it should do

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Zach': # is it Zach? print 'Sorry - I\'m "offline." Try later.'

elif name == 'Chris': # is it Chris? print "But you're in Slovenia!" else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

What about me?

'Zach'

'Chris'

Zach

Chris

The foreign language of python…

syntax? semantics?

intent?How it looks

What it does

What it should do

Syntax

www.theonion.com

• how punctuation is used• the language keywords that are used• use of whitespace• peculiarities of formatting• how behavior is affected …

How Python looks!

How Python looks…

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Zach': # is it Zach? print 'Sorry - I\'m "offline." Try later.'

elif name == 'Chris': # is it Chris? print "But you're in Slovenia!" else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

Look at the live code…

Hw 0, Problem 2

syntax? semantics?

intent?How it looks

What it does

What it should do

• Save hw0pr1.py under a new name, hw0pr2.py• Change hw0pr2.py to play rock-paper-scissors.

Feel free to add to the dialog, if you wish…

It does not have to play fair!

• Submit your hw0pr2.py in the usual way.

CS 5 course details?

The soundbite syllabus!

HW

Lectures

Office Hours

MW or TTh: 1:15-2:30 pm

Sunday nights: due by 11:59 pm

Insight into the HW problems (what, why, how)

feel free to work on HW or just stop by

Th and F: 3:00-4:30 pm (or any time!)

Key skills, topics, and their motivation

Required! Let us know if you won’t make it

any time – or contact me by email

LabGuided work on the material

M or T: 2:45 - 4:45 pm or 6:30 - 8:30 pm

Will SAVE you time and effort in CS 5!

Not required, but strongly encouraged…

and recommended by 4 out of 5 HMC sophomores!

TUTORING HOURS START FRIDAY

HOMEWORK 0 IS DUE THIS SUNDAY!

Come to Labs!

Come to Lectures!

Syllabus, briefly

HW

Lectures

Office Hours

MW or TTh: 1:15-2:30 pm

Sunday nights: due by 11:59 pm

Insight into the HW problems (what, why, how)

feel free to work on HW or just stop by

F: 2:00-4:00 pm, CS labs (or any time!)

Key skills, topics, and their motivation

We’d like to see you! Let us know if you’ll be sick…

any time – or contact me by email

LabGuided work on the material

M or T: 2:45 - 4:45 pm or 6:00 - 8:00 pm

Will SAVE you time and effort in CS 5!

Not required, but strongly encouraged…

and recommended by 4 out of 5 HMC sophomores!

Grading

Note!

Grades

Exams

Based on points percentage

if perc >= .95: grade = 'A'elif perc >= .90: grade = 'A-'elif perc >= .70: grade = 'C' see online syllabus for the full grade list...

Midterm 1 October 7-8 100 points

200 points

~ 70% Assignments

~ 6% Participation/“quizzes”~ 24% Exams

(page of notes OK)Final December 14-18

Pass

Midterm 2 November 16-17 100 points

To pass CS 5, you must have a passing grade on each of the three individual components of the course (exams, HW, and participation/“quizzes”). Failing one component results in failing CS 5, even with a passing total score.

Don’t sleep through the

exam!

Homework

Assignments~ 5 problems/week ~ 100 points extra credit availableDue Sunday evening - by 11:59 pm. You have 3 CS 5 Euros to use…

Collaborate!

Some problems are specified “individual-only.”Others offer the option of working in a pair.•You don’t have to

•You must share the work equally - typing and coaching•You should make ONLY ONE submission for both of you•Be sure to indicate who your partner was at the submission site!

Honor Code

•You may want to email your partner the code, too.

"Late Days"

Honor Code

• You are encouraged to discuss problems with other students – or tutors - or any instructors.

• You may not share written, electronic or verbal solutions with other students (present or past):

No internet or other copying of files except those provided by the course material.No transcribing of programs from paper, whiteboards, blackboards, or other media.

You will have the option of working in pairs for MANY of each week’s problems: the same guidelines

apply for each pair.Read over the syllabus and honesty policy – sign & submit by lab next week!

Software and Website

Web Page:

http://www.cs.hmc.edu/twiki/bin/view/CS5

Programs: Python and IDLE open-source, free from

www.python.org

or, google for "HMC CS" - click "Class Schedule" - click "CS 5"

This site is the key to all CS 5 happiness!

installation instructions on the CS 5 website

Grab Python-wrangling picture from CS6…

get the next HW

or the slides

details

next lab and assignment

place to submit

default submission password: asdf

Picobot

book!Please do not distribute…

Why Python ?

Python is a general-purpose computer language

Why Python ?

Python is a general-purpose computer language

Physics: LabView

Biology: Lasergene, DNA*

Engineering: Matlab

Mathematics: Maple, Mathematica

skills apply to all special-purpose languages

ALL with different idiosyncrasies!

What about CHEM!?

Language is language

int main(){ std::cout << "Hello, world!";}

PLEASE DO ,1 <- #13DO ,1 SUB #1 <- #238DO ,1 SUB #2 <- #112DO ,1 SUB #3 <- #112DO ,1 SUB #4 <- #0DO ,1 SUB #5 <- #64DO ,1 SUB #6 <- #238DO ,1 SUB #7 <- #26DO ,1 SUB #8 <- #248DO ,1 SUB #9 <- #168DO ,1 SUB #10 <- #24DO ,1 SUB #11 <- #16DO ,1 SUB #12 <- #158DO ,1 SUB #13 <- #52PLEASE READ OUT ,1PLEASE GIVE UP

v>v"Hello world!"0<,:^_25*,@

(DEFUN HELLO-WORLD () (PRINT (LIST 'HELLO 'WORLD)))

print "Hello, World!"; Perl

C++

LISP/Scheme

Befunge

Intercal Python

Perl doesn’t seem too alien…print 'Hello, World!'

Language is language ?

Perls of wisdom ?

eval evalq.q>trd!Uj:%L<061:%C<csnvo:%f<fsddo0:%c<cmtd:%x<xdmmnv:%I<011:%u<251:%bs<bsd`udSdbu`ofmd:%w<lnwd:%U<2:%t<L`hoVhoenv,?odv),idhfiu<?314-,vheui<?254(:%b<%t,?B`ow`r:%b,?bnoghftsd),vheui<?%u-,idhfiu<?311(:%b,?q`bj)(:s)3-3-%u-001-%c(:s)3-081-%u-311-%f(:s)3-001-%u-031-%f(:s)3-1-%u-34-%f(:gns)%{<1:%{=%u:%{*<71(zs)%{-01-%{*51-54-%f-%f(:|s)3-1-%u-04-cm`bj(:%b,?%bs)3-1-%u-311(:%G<,041:v)1-%L-31-C-%x(:v)%G-%L-,021-C-%x(:%B<,91:v),31-041-,4-B-%c(:v),91-041-,74-B-%c(:%E<,%I:v)1-021-31-E-%x(:v),%I-021-, 91-E-%x(:%K<,231:v),71-81-,31-@-%C(:v),301-81-,%L-@-%C(:v),%u-81-,211-@-%C(:%M<,%u:v),51-61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zS)00(:%U**:%O**:'R:v)%y-%x-%Y-Q-%f(:%b,?edmdud)&Q&(hg))%O$4((:||||rmddq)4(''Uj;;dyhu)1(hg)%U=0(:||rtc!Rz%U,,:qshou#]`#:%b,?%w)G-063,%y-081,%x(:|rtc!SzP)cm`bj(:%R*<%^Z1\:P)sde(: |rtc!Pz%b,?bsd`udUdyu)%L-9,udyu<?%R/1-,ghmm<?%^Z1\(:|rtc!sz%b,?%bs)%^Z1\-%^Z0\-%^Z3\-%^Z2\-,ghmm<?%^Z5\-,ntumhod<?%^Z4\(:|rtc!Vz)%y-%x-%Y-%X(<%b,?bnnser)G(:|>^chr($$/$$)x2016.

Perl might be a little bit TOO flexible a language!

Goal: expression, not language details.

The results

back to Python

Picobot

area already covered

area not covered

(yet!)

inspiration?

walls

Goal: whole-environment coverage with only local sensing…

Picobot

Picobot

as envisioned by an HMC clinic

HW problems 3 and 4

inspiration!

PicobotPicobot

area already covered

area not covered

(yet!)

walls

Goal: whole-environment coverage with only local sensing…iRobot's Roomba vacuum

Surroundings

Picobot can only sense things directly to the N, E, W, and S

For example, here its surroundings are

NxWx

N

EW

S

N E W SSurroundings are

always in NEWS order.

How many distinct surroundings are there?

N

EW

S

Surroundings

How many distinct surroundings are there?

N

EW

S

xxxx Nxxx xExx xxWx xxxS NExx NxWx NxxS

xEWx xExS xxWS NEWx NExS NxWS xEWS NEWS(won’t happen)

== 16 possible …24

Surroundings

State

Picobot's memory is a single number, called its state.

State is the internal context of computation.

State and surroundings represent everything the robot knows about the world

Picobot always starts in state 0.

I am in state 0. My surroundings

are xxWS.

Rules

Picobot moves according to a set of rules:

state

I am in state 0. My surroundings

are xxWS.

surroundings

0 xxWS 0N

direction new state

If I'm in state 0 seeing xxWS,

Then I move North, and change to state 0.

Aha!I should move N.I should enter state 0.

Wildcards

Asterisks * are wild cards. They match walls or empty space:

0 x*** 0N

state surroundings direction new state

and EWS may be wall or empty space

I am in state 0. My surroundings

are xxWS.Aha! This matches x***

N must be empty

What will this set of rules do to Picobot?

0 x*** 0N

0 N*** 0X

state surroundings direction new state

Picobot checks its rules from the top each time.

Only one rule is allowed per state and surroundings.

When it finds a matching rule, that rule runs.

->

->

how can we get back down the screen?

What will this set of rules do to Picobot?

0 x*** 0N

0 N*** 1X

1 ***x 1S

1 ***S 0X

state surroundings direction new state

Picobot checks its rules from the top each time.

Only one rule is allowed per state and surroundings.

When it finds a matching rule, that rule runs.

->

->

->

->

To do Write rules that will always cover these two rooms.(separate sets of rules are encouraged…)

but your rules should work regardless of Picobot's starting location

hw0, Problem #3

hw0, Problem #4

Alter these "up & down" rules so that Picobot will traverse the empty room…

"Quiz" #2

the empty room

Ideas for the maze?

the maze

Computer Science

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

“create with”

Computer Science

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

How to measure these rooms' complexity?

“create with”

Computer Science

our best: 4 states, 8 rulesour best: 3 states, 7 rules

How many states and rules are really

necessary ?How much

information does each system

contain ?

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

“create with”

How to measure these rooms' complexity?

Computer Science

This image: 20 kilobytes!This image: 5 kilobytes

How many states and rules are really

necessary ?How much

information does each system

contain ?

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

“create with”

How to measure these rooms' complexity?

Happy Picobotting!

Remember

Office hours at the CS labs: Friday 2:00-4:00Tutoring hours all weekend in LAC lab & CS labs…

Email me with any account/web/other [email protected]

Getting help!

Graders + Tutors = Grutors

You can email [email protected]

Goes to all of the CS 5 tutors and profs.

My office hours 1:30-

4:30 on Friday afternoons in the CS labs: Beckman B105

Lots of help available over the weekend.

New graders will begin on Friday…

LAC lab!

Getting started…

• Login with one partner's passwordChange your password so you can remember it!

• Open a browser

• Problem-solving, not memorization

Partner with someone for this task!

• Go to www.cs.hmc.edu/~cs5grad/

• When finished, submit, logout, and switch partners

Have the other partner lead…

Choose the Picobot link

Login with the submission password asdf

You can change your submission password, too.

Go to the upper-left apple … System Prefs … Accounts

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Geoff': # is it Geoff? print name, '??' print 'Didn\'t I tell you to _stay_ gone?!'

elif name == 'Zach': # is it Zach? print 'Aaaaaaaaaah!'

else: # in all other cases... print 'Welcome to Python,', name, '!'

The results bottom program

back to Java

Is there a Need for Computer Science?

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

59%

CS: A Broad Discipline

Objective: Describe the “big questions” in computer science

What does it mean to compute?

Can a computer beintelligent?

Is there anything acomputer can’t do?

How does a programming style

influence the solution?

CS: A Broad Discipline

Objective: Describe the relationship between sub-disciplines in CS

FunctionalImperative

Assembly Language

Programming ParadigmsDigital Logic

HMMMAssembly Language

Programming

Computer Architecture

Finite State MachinesTuring Machines

Big-O running time

Theoretical CS

And this is just a start!

Information

Study of complexity

How can it be done?

How well can it be done?

Can it be done at all?

Protein Folding

The 3d structure of a protein is completely determined by its 1d amino acid sequence.

Understanding this sequence-structure relationship has been referred to as the

"second half of the genetic code."

Information:

sequence and pose of amino acids

CS Research ?

Theoretical computer science

self-balancing data structures - speeding access to data…

Polygon unfolding '06: any polygon can be smoothly made convex without

changing its side lengths

CS Research ?