Presentation is loading. Please wait.

Presentation is loading. Please wait.

EECS 110: Recitation #1: Ionut Trestian Northwestern University

Similar presentations


Presentation on theme: "EECS 110: Recitation #1: Ionut Trestian Northwestern University"— Presentation transcript:

1 EECS 110: Recitation #1: Ionut Trestian Northwestern University

2 If statements (1) 2 name = raw_input('Hi... what is your name? ') if name == 'Ionut': # is it Ionut? print 'x1' else: # in all other cases... print 'x2' print 'x3' hw0pr1.py Homework 0, problem 1

3 If statements (2) 3 name = raw_input('Hi... what is your name? ') if name == 'Ionut‘: print 'x1' else: print 'x2' print 'x3'

4 If statements (3) 4 name = raw_input('Hi... what is your name? ') if name == 'Ionut': # is it Ionut? print 'x1' elif name == 'Aleksandar': print 'x2' else: # in all other cases... print 'x3' print 'x4' hw0pr1.py Homework 0, problem 1

5 If statements (4) 5 name = raw_input('Hi... what is your name? ') if name == 'Ionut': print 'x1' elif name == 'Aleksandar': print 'x2' else: print 'x3' print 'x4'

6 If statements (5) 6 name = raw_input('Hi... what is your name? ') if name == 'Ionut': # is it Ionut? print 'x1' elif name == 'Aleksandar': print 'x2' elif name == 'Lisa': print 'x3' else: # in all other cases... print 'x4' print 'x5' hw0pr1.py Homework 0, problem 1

7 If statements (6) 7 name = raw_input('Hi... what is your name? ') if name == 'Ionut‘: print 'x1' elif name == 'Aleksandar’: print 'x2' elif name == 'Lisa': print 'x3' else: print 'x4' print 'x5'

8 Homework problems 3 and 4 8 Picobot area not covered (yet!) Picobot walls area already covered Goal: whole-environment coverage with only local sensing … inspiration?

9 Picobot 9 area not covered (yet!) Goal: whole-environment coverage with only local sensing … area already covered Picobot walls iRobot's Roomba vacuum inspiration!

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

11 How many distinct surroundings are there? N E W S xxxxNxxxxExxxxWxxxxSNExxNxWxNxxS xEWxxExSxxWSNEWxNExSNxWSxEWSNEWS (won’t happen) == 16 possible … 2424 Surroundings

12 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.

13 Rules Picobot moves according to a set of rules: state I am in state 0. My surroundings are xxWS. surroundings 0 xxWS 0N directionnew state If I'm in state 0 seeing xxWS, Then I move N orth, and change to state 0. Aha! I should move N. I should enter state 0.

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

15 What will this set of rules do to Picobot? 0 x*** 0N 0 N*** 1X 1 ***x 1S 1 ***S 0X statesurroundingsdirectionnew 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. ->

16 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 (Extra)

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

18 Ideas for the maze? the maze Hold on to one wall !!


Download ppt "EECS 110: Recitation #1: Ionut Trestian Northwestern University"

Similar presentations


Ads by Google