Lightbot and Functions CSE 120 Winter 2018

Slides:



Advertisements
Similar presentations
 Communication:  Provide context, e.g., s …  TA Office hour for next Tuesday: CANCELLED  My name is: ??  Show  Scores on-line, Quiz-1 results.
Advertisements

Chapter 2 The Algorithmic Foundations of Computer Science
C How to Program, 6/e Summary © by Pearson Education, Inc. All Rights Reserved.
1 Boolean Algebra & Logic Gates. 2 Objectives Understand the relationship between Boolean logic and digital computer circuits. Learn how to design simple.
Operating System Principles And Multitasking
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 We’re underway …
15-100: Introduction to Programming w/ Java * Ananda Gunawardena -- Lecture – School of Computer Science – Phone : (x81559) – Office: Wean Hall.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Recursion.
The Beauty and Joy of Computing Lecture #6 Algorithms I Jon Kotker UC Berkeley EECS 2010, 2013 Microsoft
ECS – Storyboarding and Introduction to Web Design
Expressions & Control Flow CSE 120 Spring 2017
Computer Network Fundamentals CNT4007C
Lecture 1b- Introduction
ICS 3UI - Introduction to Computer Science
Mobile Testing - Bug Report
Computer Networks CNT5106C
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Operating Systems (CS 340 D)
Processing Introduction CSE 120 Spring 2017
Chapter 2: Input, Processing, and Output
Copyright © 2008 by Helene G. Kershner
Functions in Processing CSE 120 Spring 2017
IF statements.
Lightbot and Functions CSE 120 Winter 2017
Copyright © 2008 by Helene G. Kershner
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Algorithm Analysis CSE 2011 Winter September 2018.
Algorithmic Complexity CSE 120 Winter 2018
Mid-Quarter Review CSE 120 Winter 2018
Functions in Processing CSE 120 Winter 2018
Puzzle App II CSE 120 Winter 2018
Basic Input and Output CSE 120 Winter 2018
Variables & Datatypes CSE 120 Winter 2018
Computer Programming.
Writing to Learn vs. Writing in the Disciplines
Computer Networks CNT5106C
Processing and Drawing CSE 120 Winter 2018
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Looping and Repetition
Learning to Program in Python
Stepwise Refinement Eric Roberts CS 106A January 8, 2010.
Expressions & Control Flow CSE 120 Winter 2018
Binary Numbers CSE 120 Spring 2017
Objective of This Course
Variables & Datatypes CSE 120 Spring 2017
UNIT 3 CHAPTER 1 LESSON 4 Using Simple Commands.
Strings, Puzzle App I CSE 120 Winter 2018
Nested Loops, Arrays CSE 120 Winter 2018
Loops CIS 40 – Introduction to Programming in Python
Algorithms CSE 120 Winter 2018 Instructor: Teaching Assistants:
Background and Motivation
Testing and Repetition
Maze Challenge Maze Challenge activity > TeachEngineering.org
Caches III CSE 351 Autumn 2018 Instructor: Justin Hsia
Two Paths Diverge in the Lectures
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
IPC144 Introduction to Programming Using C Week 4 – Lesson 1
- When you approach operating system concepts there might be several confusing terms that may look similar but in fact refer to different concepts:  multiprogramming, multiprocessing, multitasking,
Loops & Nested Loops CSE 120 Winter 2019
Chapter 5 Architectural Design.
Computer Networks CNT5106C
Running a Java Program using Blue Jay.
CSE 153 Design of Operating Systems Winter 2019
CSCE 206 Lab Structured Programming in C
Classes and Objects Object Creation
Chapter 3: Process Management
Today: to list: Syllabus change: Grade on-line
Expressions & Conditionals CSE 120 Winter 2019
CMSC 202 Constructors Version 9/10.
Presentation transcript:

Lightbot and Functions CSE 120 Winter 2018 Instructor: Teaching Assistants: Justin Hsia Anupam Gupta, Cheng Ni, Eugene Oh, Sam Wolfson, Sophie Tian, Teagan Horkan Meltdown and Spectre: Bugs in modern computers leak passwords and sensitive data “Meltdown and Spectre exploit critical vulnerabilities in modern processors. These hardware bugs allow programs to steal data which is currently processed on the computer. While programs are typically not permitted to read data from other programs, a malicious program can exploit Meltdown and Spectre to get hold of secrets stored in the memory of other running programs. This might include your passwords stored in a password manager or browser, your personal photos, emails, instant messages and even business- critical documents.” https://spectreattack.com/

Administrivia Website navigation [demo] Lab checkoffs Labs done in pairs, have multiple attempts to complete Generally due before next section; later labs are longer Can get checked off by any staff member in Section or OH Homework submission Submit via Canvas Assignments page Make sure you look at Canvas rubrics Lightbot Functions assignment due Monday (1/8)

TA Office Hours CSE 2nd floor breakout Up the stairs in the CSE Atrium (next to the café) At the top of that first flight, the open area with the whiteboard wall is the 2nd floor breakout!

As Experienced Lightbot Players… What are you doing in Lightbot? Commanding a robot through a world of blocks and switches

As Experienced Lightbot Players… What are you doing in Lightbot? Commanding a robot through a world of blocks and switches Programming is commanding an agent In this case, the agent is a robot The agent is usually a computer, but could be a person or other device

As Experienced Lightbot Players… What are you doing in Lightbot? Commanding a robot through a world of blocks and switches Programming is commanding an agent In this case, the agent is a robot The agent is usually a computer, but could be a person or other device Direct an agent to a goal by giving it instructions The agent follows the instructions flawlessly and mindlessly The trick is to find the right instructions to match your intent

Order of Instructions Instructions are given in order (i.e. in a sequence) The 1st instruction is completed, then the 2nd, then the 3rd, … You issue the instructions and the agent follows them When the agent is following your instructions, this is called executing the program, or running the program

Order of Events The instructions are programmed ahead of time, and then executed later The programmer cannot intervene until the program has finished executing or is terminated prematurely The instructions must be correct in order for the agent to achieve its goal

Point of View Programming requires you to take the agent’s point of view Because it is a sequence of instructions, you must account for everything that happened before (i.e. trace the program) There is usually an indication of where you are currently in the program (sometimes called a program counter)

Limited Instructions The number and type of instructions is always limited The agent can only do certain pre-defined actions The agent can only execute one instruction at a time Must learn how to specify complex tasks using just these simple actions Examples: chess knight movement

Limited Instructions Limited instructions is a reality of all computing A computer’s hardware/circuitry can only execute a small number of instructions – usually about 100 Many are just different versions of the same idea Amazing Fact: In theory, a computer with just SIX instruction types could compute all known computations!

Back in Reality Programming would be amazingly tedious if you could only use the basic instructions No one would be a programmer no matter how much it paid! The amazing applications we see today would not exist The early days of programming were like this Tedious and error-prone Muscle/neuron firing analogy for standing up

Solution: Functions! Functions allow us to create new, more complex subtasks for our agents Below, F1 is a function to “process a riser” We can call a function by name (F1) to execute its instructions

Choosing Functions The goal is to break down a complex problem into smaller/simpler ones Look for common patterns “Process a riser” looks like a useful sub-problem because there are three of them [DEMO] Point 1: Abstraction Point 2: Generalization

Choosing Functions One possible solution is shown below: 17 commands, 29 calls

Choosing Functions Modified solution is shown below: Now F2 is a function to “move to next riser” 16 commands, 31 calls 5 conceptual steps rather than 26 bare instructions

Choosing Functions Yet another solution shown below: 12 commands, 35 calls 3 repeated conceptual steps F1 is “traverse steps” F2 is “process riser and move to next”

Recursion Special case where a function calls itself “Conceptual unit” might apply again, immediately

Peer Instruction Question Which of the following statements is TRUE? Vote at http://PollEv.com/justinh An agent can learn new instructions It is the agent’s fault if the goal is not achieved All ways to decompose a problem into functions are equally good None of the above We’re lost… Metrics: Execution time Program size Does it work? How easy is it to understand?

Functions Summary Functions may seem “obvious” to you, but they are a foundational idea of computer science Abstraction in action! Functional abstraction helps us solve problems: Reduce complexity: identify and solve a coherent activity or action (sub-problem) that can be reused Associate these sub-problems with intuitive names Solve the whole problem by composing functions There is no “correct” way to abstract!

Looking Forward Continue to explore the concept of programming in the realm of Lightbot Lightbot (checkoff) due before lab on 1/9 Symbolic Lightbot (checkoff) due before lab on 1/9 Lightbot Functions (submitted) due end of 1/8 Create functions using handwritten symbols F.turnaround() R,R.