22
Solving Problems in CS CS 100: Introduction to the Profession Michael Saelee; [email protected]

Solving Problems in CS

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Solving Problems in CS

Solving Problems in CSCS 100: Introduction to the Profession Michael Saelee; [email protected]

Page 2: Solving Problems in CS

Computer ScienceScience

Course website:

http://moss.cs.iit.edu/cs100

Page 3: Solving Problems in CS

Computer ScienceScience

Day 2 takeaway: CS is about solving problems

Page 4: Solving Problems in CS

Computer ScienceScience

- What problems?

- How to represent these problems?

- How efficiently can we solve them?

- Is it possible to solve them?

Page 5: Solving Problems in CS

Computer ScienceScience

What problems?

- theoretical CS: mathematical/abstract

- e.g., if we can verify the solution to a given problem quickly, can we also solve it quickly? (aka P=NP?)

- applied CS: real-world problems

- e.g., can we get a robot to reliably explore every corner of a room?

Page 6: Solving Problems in CS

Computer ScienceScience

How to represent these problems?

- i.e., so that a computer can be used to can automate their solutions

- typically many possible representations

- choice may be limited by real-world constraints!

Page 7: Solving Problems in CS

Computer ScienceScience

Picobot implementation by, and figures adapted from Zach Dodds and Wynn Vonnegut, Harvey Mudd College

walls

area not yet covered

Picobot

area already covered

Page 8: Solving Problems in CS

Computer ScienceScience

What does the bot need to sense/remember in order to fully explore the room?

Page 9: Solving Problems in CS

Computer ScienceScience

So many options!

- our goal: only local sensing - i.e., immediate surroundings only

- minimizes hardware cost

Page 10: Solving Problems in CS

Computer ScienceScience

N

EW

S

NxWxN E W S

Surroundings are always in NEWS order.

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

E.g., N and W are obstructed, while E and S are clear

Page 11: Solving Problems in CS

Computer ScienceScience

xxxx Nxxx xExx xxWx xxxS NExx NxWx NxxS

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

Answer: 24 = 16

N

EW

S

How many possible surroundings?

Page 12: Solving Problems in CS

Computer ScienceScience

In addition to its sensors, Picobot also has:

1. knowledge of its current state 2. a list of rules (its program) dictating

movement and state transitions based on its current state and surroundings

Page 13: Solving Problems in CS

Computer ScienceScience

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

State is the internal context of computation.

Picobot always starts in state 0.

I am in state 0. My surroundings

are xxWS.

State

Page 14: Solving Problems in CS

Computer ScienceScience

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

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

If I'm in state 0seeing xxWS,

Then I move North, and change to state 0.

Page 15: Solving Problems in CS

Computer ScienceScience

Wildcards

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

0 x*** 0N

state surroundings direction new state

I am in state 0. My surroundings

are xxWS.Aha! This matches x***

here, EWS may be wall or empty space

Page 16: Solving Problems in CS

Computer ScienceScience

What will this set of rules do to Picobot?

0 x*** 0N0 N*** 1X

1 ***x 1S1 ***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.

->->

->->

Page 17: Solving Problems in CS

Computer ScienceScience

How efficiently can we solve them?

- how long does it take a computer to solve increasingly harder versions of the same problem?

Page 18: Solving Problems in CS

Computer ScienceScience

Page 19: Solving Problems in CS

Computer ScienceScience

- What is the minimum number of states and rules to traverse each room?

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

Page 20: Solving Problems in CS

Computer ScienceScience

Is it possible to solve them?

- given a problem and its chosen representation, can we automatically solve every instance of it in finite time?

Page 21: Solving Problems in CS

Computer ScienceScience

- Can you write a set of rules to traverse every possible room?

- How would you measure the complexity of a given room?

Page 22: Solving Problems in CS

Computer ScienceScience

Have fun!

When you’ve solved the first two rooms, create a “secret gist” containing your rules and submit it via the form on the website.

Try solving the harder rooms, if you want!