Introducing Karel

Calvin (Deutschbein)
Slides by Jed Rembold

10 January 2022

Announcements

  • Welcome to CS-151: Intro to Programming with Python!
  • Things to do:
    • Access the course webpage at cd-public.github.io/courses/intro/151s22.html
      • There will be a link to the course webpage from the WISE site
    • Look over the syllabus
    • Access the textbook
    • Join the Discord!
      • You should have gotten an email
  • Homework
    • The first homework, Problem Set 0 (PS0) will be posted to Discord after class, due next Friday, 1/21
    • Labs/sections will make sure you are setup with everything you need and have been introduced to the process

About Me

Name
Calvin (Deutschbein)
Office
Ford 206
Office Hours
For now: Zoom by appt (email or discord me)
Tuesdays and Thursdays are better.
Email:
ckdeutschbein@willamette.edu

Motivations

  • The field of computing today is scarcely recognizable compared to the field 50 years ago.
  • Many feel the pace of the field is only accelerating as we move forwards.
  • Studying computing now lets you take part in driving forward not only the field of computing, but of all the modern fields with utilize computing.
    • Almost all fields!

Learning Objectives

To gain the skills, knowledge, and confidence necessary to write, test, and debug Python programs requiring several hundred lines of code.

Doing so will require that students be able to:

  • implement algorithms,
  • decompose complex problems,
  • use recursion,
  • design programming structures,
  • do each of: design, implement, test and debug,
  • argue that computer science is more than programming.

Grading

  • Standard 90/80/70 etc grade cut-offs
    Homework 40%
    Midterms 40%
    Final Project 20%

Grading

  • Standard 90/80/70 etc grade cut-offs
    Problem Sets 20%
    Projects 20%
    Midterm I 20%
    Midterm II 20%
    Final 20%

Participation

  • I reserve the right to raise individual student grades in accordance with strong participation in class, office hours, or on Discord.

Homework

  • Falls into two categories:
    • Problem Sets: smaller, more focused assignments
    • Projects: larger, more integrative assignments
  • All will be due on Fridays at 9:10 AM
  • Submissions of both will be handled through Github Classroom
    • Learning how to do this is part of this weeks lab sections.
  • Late homework is not accepted - turn it what you have, then be caught up for the next assignment.
  • Instead of a late policy, I will drop the lowest homework score at the end of the semester.

Project Sneak Peeks!

Labs/Sections

  • New pilot program just started last year!
  • Everyone will be placed into small sections of 5-7 students, with one section leader
  • All section leaders are students who recently took and excelled in this course
  • Will meet as a group with your section leader once a week for an hour to go over and work on problems
  • Section leaders will also serve as a secondary source for help or guidance.

Tests

  • Tests are a useful tool to promote directed thinking about the science of computing in isoloation from a programming environment.
  • Just two this semester:
    • Midterm I week of 2/21
    • Midterm II week of 4/11
  • Having two tests reduces the stakes of the individual test and hopefully reduces stress as well! We will use simple vote to decide what day of these weeks to offer the tests.
  • Tests will be taken in class* and will actually not allow the use of a computer
    • This policy has actually been seen to improve student learning, as it prevents you from wasting tons of time obsessing about a small mistake!
  • Example tests and study materials will be given out a week in advance.

Communication

  • I tend to find WISE lacking both from a polish perspective and from an ease of use perspective
  • I will be using a 3rd-party forum to focus class communication, announcements, and questions: Discord.
  • You should have gotten an email with invite instructions. Let me know if you have not!
  • Totally free to sign up and use

Academic Honesty

  1. You must not look at solutions or program code that is not your own.
  2. You must not share your solution code with other students.
    • But you are welcome (and encouraged!) to work alongside others enroute to finding a solution.
  3. You must indicate on your submitted assignment any assistance you received or who you worked alongside.

Diving In

  • This course is an introduction on computer science, and covers more than just programming!
  • Python is used to teach the programming portion of the course, but the focus is less on Python itself and more on general computer science principles.
  • If you come across situations where you need to know a bit more about specific Python details, there are plenty of resources online, or just ask me!

Effective Communication

  • To communicate effectively with someone or something, you really need two layers of communication:
    • A shared language or method of conveying information
      • French, for instance
      • In our case, Python
    • A joint agreement about what constitutes meaning and ways to limit confusion or misunderstanding
      • Being able to explain things clearly and unambiguously

Giving Clear Instructions

  • We will initially make the language extremely simple so that we can focus on the second layer
  • Karel the Robot exists in a very simple 2D world
  • Has a very limited set of actions:
    • Can move forward one space
    • Can rotate counter-clockwise (turn left) 90 degrees
    • Can pick up a beeper
    • Can drop off a beeper
  • We will be spending the first several class days just interested in how we can take these simple instructions and get Karel to solve a wide variety of problems
    • This content is not in your book, but more in-depth descriptions can be found here

The World

  • Karel’s world is defined on a grid
    • avenues run north-south
    • streets run east-west
    • The intersection between a street and avenue is called a corner
  • Compass directions are as you’d have them on a map, with North pointing upwards
  • Walls are impassable
  • Beepers are diamonds
  • Karel is a house-shaped polygon

Commands

  • As we mentioned before, Karel is a simple robot, and can really only do 4 potential actions
Command Action
move() Moves Karel forward one corner in whatever direction they are facing
turn_left() Rotates Karel 90 deg counter-clockwise
pick_beeper() Picks up a beeper on the ground
put_beeper() Places a beeper on the ground
  • Our commands are just sequences of these actions

Example

  • Suppose we had the situation to the right and wanted to navigate to the beeper, pick it up, and then drop it at the corner of 1st avenue and 1st street.
  • Take a moment to write out your instructions.
    • Remember you can only move, rotate left, and pick up or drop the beeper
  • Note that there are multiple ways to do this! Which is better?

One Solution

def main():
    move()
    turn_left()
    turn_left()
    turn_left()
    move()
    turn_left()
    move()
    turn_left()
    turn_left()
    turn_left()
    move()
    pick_beeper()
    turn_left()
    turn_left()
    turn_left()
    move()
    move()
    put_beeper()
// reveal.js plugins