The CS5 Times Eager Penguins Invade Computer Lab

Slides:



Advertisements
Similar presentations
Mon: CS + programming Tue: Data Wed: Algorithms
Advertisements

EECS 110: Recitation #1: Ionut Trestian Northwestern University
The Beauty and Joy of Computing Lecture #18 Besides Blocks I: Intro to Python Amazon Dash is Not an April Fools Joke UC Berkeley EECS Head TA Michael Ball.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
EECS 110: Lec 2: What is Programming?
CS != programming What is computer science (CS)? Take CS 121.
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University
Picobot area already covered area not covered (yet!) inspiration? walls Goal: whole-environment coverage with only local sensing … Picobot as envisioned.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Comp1202: Conclusions Revision Session. Coming up Key Concepts - The Pillars HashMaps Exceptions The Exam Some Last Words.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
Basic concepts of C++ Presented by Prof. Satyajit De
EGR 2261 Unit 11 Pointers and Dynamic Variables
CS 106 Computing Fundamentals II Chapter 5 “Excel Basics for Windows”
Enrollment for the school year at Rocky is about to begin
Topics Designing a Program Input, Processing, and Output
CS1022 Computer Programming & Principles
Roomba! Goal: whole-environment coverage Problem motivation
Formatting Output.
Building Java Programs
Introduction to Programming
EECS 110: Lec 2: What is Programming?
CS 332: Algorithms Hash Tables David Luebke /19/2018.
What is computer science (CS)?
Variables and Primative Types
Functions CIS 40 – Introduction to Programming in Python
The CS 5 Times Penguin/Pig Gang Fight Brings Violence to Claremont
The CS 5 Black Post Penguins Invade Dormitory
CS190/295 Programming in Python for Life Sciences: Lecture 1
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
String Output ICS 111: Introduction to Computer Science I
Welcome Back to CS 5 Black!
Introduction to Programming
Winter 2018 CISC101 12/2/2018 CISC101 Reminders
Coding Concepts (Sub- Programs)
Building Java Programs
Teaching London Computing
How to Run a Java Program
Introduction to Programming
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Building Java Programs Chapter 2
CS150 Introduction to Computer Science 1
Building Java Programs
Topics Designing a Program Input, Processing, and Output
Building Java Programs
Picobot Challenge! inspiration? walls Picobot area not covered (yet!)
Building Java Programs
Building Java Programs
Topics Designing a Program Input, Processing, and Output
Introduction to Primitives
Introduction to Primitives
CISC101 Reminders Assignment 3 due next Friday. Winter 2019
Introduction to Programming
Building Java Programs
Beginning Python Programming
Selection Statements Chapter 3.
Building Java Programs Chapter 2
WEEK 8 COURSE PROJECT PRESENTATION NAME: ALEXANDER WEISS CLASS: CIS115.
Building Java Programs
Building Java Programs
CSCE 206 Lab Structured Programming in C
CSE 326: Data Structures Lecture #14
Roomba! Goal: whole-environment coverage Problem motivation
Ionut Trestian Northwestern University
Presentation transcript:

The CS5 Times Eager Penguins Invade Computer Lab Claremont (AP): The first-day offering of Harvey Mudd’s popular CS5 laboratory was disrupted when a large flock of penguins took every seat in the room. “They’re cute,” complained a distraught student, “but they smell like fish and there’s no room for us.” Professors attempted to drive the penguins away by repeatedly shouting “Shark!”, but the penguins were unmoved. Before lecture begins, have a browser window with Picobot, and have the maze solution ready to paste in so you can demo solving the maze. Handouts (read them all!): Today’s lecture notes A preprinted blank "worksheet” Light reading? ;^) (Official course alien) Prof. Geoff Kuenning, Olin 1255 http://www.cs.hmc.edu/~geoff/geoff-schedule.html

Overview Weeks 1-3: Thinking functionally Weeks 4-6: Computer organization Weeks 7-10: Oops! (Object oriented programs) Weeks 11-14: Theoretical foundations Capstone Project! 14 weeks of action-packed excitement!

Programming Languages… * A-0 programming language * ABAP * ABC * ABC ALGOL * ABLE * ABSET * ABSYS * ACC * Accent * ACT-III * ATOLL - Acceptance, Test Or Launch Language * Action! * ACS * ActionScript * Actor * Ada 2000 languages omitted * YAFL * Yellow - Rejected prototype for Ada * Yorick * Y Language * Z notation - A program specification language, like UML * ZOPL. * ZPL * ZUG * ZZT-oop

Python Relatively “nice” syntax Emerging as language of choice in many fields Packages for graphics, audio, scientific computing, … print(“Hello World”) Python Prof. Geoff takes on Python… class HelloWorld { static public void main( String args[] ) { System.out.println( "Hello World!" ); } Java Befunge

Hello World… C++ Ook #include <iostream.h> main() { cout << "Hello World!" << endl; return 0; } C++ Ook

Some Things You’ll Do This Semester… Sequence alignment ATTATCG ACATTC ATTATCG -> A TATCG -> A CAT_CG -> A CATTCG -> A CATTC Delete T Change T to C Insert T here Delete G Distance is 4 ATTAT-CG A-CATTC-

Spel Cheking…

Huffman Data Compression

Connect 4 AI

It makes people think you’re fun to be with. The Alien's Life Advice SMILE! It makes people think you’re fun to be with.

Picobot! DEMO! Reading: Chapter 1 in the book This language is not Turing-Complete. I guess that makes it “unreasonable”! Reading: Chapter 1 in the book (http://www.cs.hmc.edu/csforall/) walls Picobot area not covered (yet!) area already covered Murata Girl Demo can be found at http://www.cs.hmc.edu/picobot Book is at http://www.cs.hmc.edu/csforall/ Goal: whole-environment coverage with only local sensing… Roomba DEMO!

Surroundings are always in NEWS order. Environment in the NEWS! Picobot can only sense things directly to the N, E, W, and S N W E S For example, here its surroundings are NxWx Surroundings are always in NEWS order. N E W S

Surroundings How many distinct surroundings are there? N W E S 24 == 16 possible … 24 xxxx Nxxx xExx xxWx xxxS NExx NxWx NxxS xEWx xExS xxWS NEWx NExS NxWS xEWS NEWS (won’t happen)

State I am in state 0. My surroundings are xxWS. Picobot's memory is a single number, called its state. State is the internal context of computation. Picobot always starts in state 0. State and surroundings represent everything the robot knows about the world

Rules Aha! I should move N. I should enter state 0. I am in state 0. My surroundings are xxWS. Picobot moves according to a set of rules: A capital “X” here means “Don’t Move” state surroundings direction new state xxWS N If I'm in state 0 seeing xxWS, Then I move North, and change to state 0.

Wildcards Aha! This matches x*** state surroundings direction I am in state 0. My surroundings are xxWS. Aha! This matches x*** Asterisks * are wild cards. They match walls or empty space: state surroundings direction new state x*** N and EWS may be wall or empty space N must be empty

What Will This Set of Rules Do to Picobot? A capital “X” here means “Don’t Move” state surroundings direction new state x*** -> N N*** -> X Add some code here to make Picobot go up and down in the same column forever! Picobot checks its rules from the top each time. When it finds a matching rule, that rule runs. Only one rule is allowed per state and surroundings.

What Will This Set of Rules Do to Picobot? state surroundings direction new state x*** -> N N*** -> X 1 1 ***x -> S 1 1 ***S -> X Picobot checks its rules to find one that applies When it finds a matching rule, that rule runs. Only one rule is allowed per state and surroundings.

This Week! Lab Problem Problem 2 DEMO! Write rules that will always cover these two rooms. (separate sets of rules are encouraged…) Lab Problem Problem 2 Your “program” can be slow but it should work for any starting location and for any wall-connected maze! DEMO! our best: 3 states, 7 rules (but Cam Zhou had 6) our best: 4 states, 8 rules

What’s the Point? Simple syntax can support “powerful” computation: The picobot language syntax is very simple, yet it can control a robot in a complex environment. Computer scientists examine limitations of languages: Are there environments that the picobot language cannot navigate? If so, what features could be added to give the language more “power”?

How About “General” Rooms? It turns out that Picobot can’t solve a general maze. However, if you add the ability to drop, detect, and pick up markers, and provide only three (?) markers, a general maze can be solved. Picobot has 100 states, but the “room” could be arbitrarily big and weird!

Python and the Command Line I goofed here No worries, just try again Addition, multiplication, division 1/3 vs 1/3.0 Naming values Import math Math functions Lists and range List functions (e.g. sum, max) This way I don’t have to say math.pi Python makes it easy to experiment!

Python and the Command Line Addition, multiplication, division 1/3 vs 1/3.0 Naming values Import math Math functions Lists and range List functions (e.g. sum, max) Python makes it easy to experiment!

Defining Your Own Functions! def dbl(x): return 2 * x x dbl 2 * x Notice the indentation. This is done using “tab” and it’s absolutely necessary! def dbl(myArgument): myResult = 2 * myArgument return myResult Two functions here (second animate) are equivalent. You can choose variable names, and you can assign the result or just return it. Sublime often indents for you! “Outdent” with shift-tab!

Docstrings! def dbl(x): ”””This function takes a number x and returns 2 * x””” return 2 * x This is sort of like teaching your programs to talk to you!

Docstrings…and Comments # Doubling program # Author: Ran Libeskind-Hadas # Date: August 27, 2011 # Time Spent: 14 hours def dbl(x): ”””This function takes a number x and returns 2 * x””” return 2 * x

Composition of Functions def quad(x): return 4 * x x quad 4 * x def quad(x): return dbl(dbl(x)) Doubly cool!

Multiple Arguments... x, y myFunc x + 42 * y # myFunc That’s a kind of a funky function! # myFunc # Author: Ran Libeskind-Hadas # Date: August 27, 2011 def myFunc(x, y): “””returns x + 42 * y“”” return x + 42 * y

Mapping with Python... def dbl(x): “””returns 2 * x“”” return 2 * x >>> list(map(dbl, [0, 1, 2, 3, 4])) [0, 2, 4, 6, 8] def evens(n): myList = range(n) doubled = list(map(dbl, myList)) return doubled Alternatively…. def evens(n): return list(map(dbl, range(n)))

reduce-ing with Python... from functools import reduce def add(x, y): """returns x + y""" return x + y >>> reduce(add, [1, 2, 3, 4]) 10 add add add

Google’s “Secret” This is what put Google on the map!

Try This… Write a function called span that returns the difference between the maximum and minimum numbers in a list… >>> span([3, 1, 42, 7]) 41 >>> span([42, 42, 42, 42]) min(x, y) max(x, y) These are built in to Python!

Try This... Write a python function called gauss that accepts a positive integer N and returns the sum 1 + 2 + … + N 2. Write a python function called sumOfSquares that accepts a positive integer N and returns the sum 12 + 22 + 32 + … + N2 You can write extra “helper” functions too!