- By
**bary** - Follow User

- 339 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about 'final project ideas and FSMs' - bary

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

April and May in IST380

4/21+28 ~ FSMs

5/5 ~ project work

final project ideas and FSMs

Final milestone due 5/7

Final project due 5/14

hw7-9 now graded!

assignments 9 and 10

final project work sessions

project: milestone + final

(1) define "computer" precisely

(2) define "compute" precisely

(3) see what computers provablycan't compute

(4) go to step (1) and define things better

(5) Or, head back to programming!

Foundational Ideas…

In CS, the computer doesn't matter!

this may seem big-O(bvious) recently…

Quantum interactions

with DNA or RNA

Silicon-based switching

Mechanical computation

Using marbles!

We want to capture the fundamental processes of all of these machines...

relay-based computer

http://www-03.ibm.com/ibm/history/exhibits/markI/markI_reference.html

Grace Hopper + Howard Aiken, Harvard ~ 1944

ran at 0.00001 MHz

5 tons

530 miles of wiring

765,299 distinct parts!

Addition: 0.6 seconds

Multiplication: 5.7 seconds

Division: 15.3 seconds

Grace Murray Hopper ’28 taught math and physics at Vassar for 12 years before joining the Navy reserves in 1943. During the war she learned to program the Mark I, the world’s first large-scale computer, which was used to perform the calculations needed to position the Navy’s weaponry: guns, mines, rockets, and, eventually, the atomic bomb.

In 1945, she coined the term “debugging” after finding a moth stuck in the computer’s machinery. Over the course of her career, Hopper invented the compiler to automate common computer instructions, became the first to start writing computer programs in English, and helped to develop the first “user-friendly” computer language, COBOL

GMH dedications

“In the days they used oxen for heavy pulling, when one ox couldn't budge a log, they didn't try to grow a larger ox. We shouldn't be trying for bigger and better computers, but for better systems of computers.”

I'm glad it's not called demothing.

0 NEWx -> S 1

next state

previous state

next step

external input

literally!

The state of a computation is

all the internal information needed to take its next step

Computation is simply a deliberate sequence of state-changes

doesn't seem very meaningful

0110110101011010010001

0110110101000000001110

bits before

bits after

That's a 2-bit computer!

“Finite State Machine”

Deterministic

0

0

Every state has one transition for every possible character.

1

q0

q1

1

Finite

start state

transition

final (accepting) state

key resource is number of states

“input funnel”

“where to go”

double circled

00101

Example Inputs:

100011

What is the language this FSM accepts?

0

1

s1

1

s0

0

s2

0,1

List three different inputs that this FSM accepts:

List three different inputs that this FSM rejects:

In general, what English phrase describes the accepted inputs?

This machine accepts strings that…

s0 means the input…

What does each state say about the current state of the input?!?

s1 means the input…

s2 means the input…

Draw a FSM accepting strings in which the number of zeros (0s) is a multiple of 3, so there are 0, 3, 6, … zeros. 1s don't matter.

Build-your-own FSMs

Draw a FSM that accepts strings that don't contain the pattern 110 anywhere.

Accepted: 110101110, 11, 0000010

Rejected: 101, 0000, 111011101111

Hint: modify the first FSM we considered!

Accepted: 1010001 Rejected: 101001100

Hint: modify the previous FSM!

Draw a FSM accepting strings in which the third digit (from the left) is a 1.

Draw a FSM accepting strings whose third-to-last digit (from the right) is a 1.

Accepted: 1010001 Rejected: 11000100 and 11

Accepted: 0100 and 01101 Rejected: 101001 and 11

Extra: Do your solutions use the minimum possiblenumber of states?

Draw a FSM accepting strings that do NOT anywhere contain the pattern 110

0

start

end w/1

end w/11

fail!

1

0

1

Minimum possiblenumber of states?

Draw a FSM accepting strings in which the number of zeros (0s) is a multiple of 3, so there are 0, 3, 6, … zeros. 1s don't matter.

Accepted: 110101110, 11, 0000010

Rejected: 101, 0000, 111011101111

Minimum possiblenumber of states?

Draw a FSM accepting strings in which the third digit (from the left) is a 1.

Accepted: 1010001

Rejected: 11000100 and 11

Minimum possiblenumber of states?

Third-to-last character is a 1?

Draw a FSM accepting strings whose third-to-last digit (from the right) is a 1.

Accepted: 0100 and 01101

Rejected: 101001 and 11

Minimum possiblenumber of states?

s110

s111

s000

s001

s010

s011

s100

s101

s11

s10

s01

s00

s0

s1

Third-to-last character is a 1

1

0

1

0

0

1

1

1

0

1

0

1

0

0

Something seems missing…

s000

s001

s010

s011

s100

s101

s110

Third-to-last character is a 1

8 states?

Can we do better than 8 states?

qstart

q1

q2

q3

q4

q5

Locks

q12

q13

q14

q15

q23

q12,3

q12,4

q12,5

There’s a lot missing here!

q12,5,34

penny, fifty cent piece,

silver dollar, Canadian

currency, Euro, ….

qstart

nickel

select drink

dime

quarter

q5 cents

q10 cents

q25 cents

nickel

dime

mechanical

vending machine

nickel

nickel

q15 cents

q20 cents

nickel

(some transitions not shown)

singled out as a questionable use of dollars...

MIT's car, Talos

MIT's car, Talos- and its sensor suite

still works

still broken

it's broken

stop adding features + start adding print statements

comment out print statements + start adding more features

it works

Simplest model of computation: FSMs

Finite State Machines

0

0

1

s0

s1

1

start state

transitions

accepting states

“input funnel”

“where to go”

double circled

labeled by input !

Are there limits to what FSMs can do?

Let's build a FSM that accepts bit strings with the SAME NUMBER of 0s as 1s

0

1

same # of 0s and 1s

FSMs can't count

at least, not arbitrarily high...

We need a more powerful model than FSMs...

so, "we" add memory !

where "we" == Turing

Alan Turing says yes...

Turing called them Logical Computing Machines

Turing’s Intelligent Machines, 1948

http://www.alanturing.net/turing_archive/archive/l/l32/L32-005.html

So far, all known computational devices can compute only what Turing Machines can...

some are faster than others…

Quantum computation

http://www.cs.virginia.edu/~robins/The_Limits_of_Quantum_Computers.pdf

Molecular computation

http://www.arstechnica.com/reviews/2q00/dna/dna-1.html

Parallel computers

Integrated circuits

Electromechanical computation

Water-based computation

Tinkertoy computation

AI!

1912-1954

WWII

Enigma machine ~ The axis's encryption engine

unfortunately, it's not Turing's Apple…

2007

1946

Bletchley Park

A simple model of universal computation.

Starts on the leftmost character

The tape: an expandable amount of memory made of ofcells, each with exactly one character: 0, 1, blank…

Read/write head for the tape

The control: a finite state machine

Ability to move left and right

The control state

The symbol now under the head

The symbols to the right of the head

The symbols to the left of the head

The complete state of a TM is determined by:

0

1

0

1

0

the tape

R/W head

"blanks" are everywhere else

an accepting state always halts -- then basks in its success!

if a transition is missing, the input FAILS!

0

;

1

,

R

a Turing Machine rule:

READ

WRITE

MOTION

try it in JFLAP...

Run this TM on this input:

0

0

1

1

1

Is thisinput accepted or rejected?

What does this TM do in general?

Change the input to one that does the opposite (reject/accept) as this!?

Extra: How could you change this TM to accept palindromes?

(extra!)

Alan Turing says No!

http://www.cs.virginia.edu/~robins/Turing_Paper_1936.pdf

There are many problems computers can't solve at all !

Perhaps this is not that surprising…

What!?

- global warming

- disbelief in aliens

- anything at all (when using Windows Vista)

Here are two useful functions that we will show can't be computed…

Kolmogorov Complexity

kc( x )

~ the complexity of an integerx

Halt Checking

hc( f )

~ does f()halt or loop forever?

What might the complexity of an integer be?

59049 zeros total

100000000000000000000000000…00000

each of these integers has 59050 digits

170117684200068728224888577…85601

same number of total digits as above

Which one "feels like" the more complex number... Why ?

The complexity of x is the length of the shortest zero-input function that outputs x.

Andrei Kolmogorov

1903-1987

Kolmogorov Complexity

kc( 42 ) = 18

The int 42 has a complexity of 18.

Why 18 ?

The complexity of x is the length of the shortest zero-input function that outputs x.

Andrei Kolmogorov

1903-1987

Kolmogorov Complexity

kc( 42 ) = 18

def f(): return 42

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

… because Python has 16 characters of overhead

What's the complexity of 1000…000 ?

59049 zeros

There are lots of 0-input functions that output that number:

function length

59066

def f(): return 1000…000

59049 zeros

def f(): return

def f(): return

The shortestdefines the complexity.

1e59049 ~ wow!

What's the complexity of 1000…000 ?

59049 zeros

There are lots of 0-input functions that output that number:

function length

59066

def f(): return 1000…000

59049 zeros

25

def f(): return 10**59049

def f(): return

The shortestdefines the complexity.

1e59049 ~ wow!

What's the complexity of 1000…000 ?

59049 zeros

There are lots of 0-input functions that output that number:

function length

59066

def f(): return 1000…000

59049 zeros

25

def f(): return 10**59049

24

def f(): return 10**9**5

24

The shortestdefines the complexity.

1e59049 ~ wow!

What's the complexity of 1000…000 ?

59049 zeros

There are lots of 0-input functions that output that number:

function length

Challenge: what is the complexity of 59049?

59066

def f(): return 1000…000

It's NOT 24.

59049 zeros

25

def f(): return 10**59049

24

def f(): return 10**9**5

24

The shortestdefines the complexity.

1e59049 ~ wow!

Kolmogorov Complexity

+2

example

Python has 16 chars of setup

more

18

1

2

3

4

5

6

7

8

9

17

18

10

11

12

13

14

15

16

kc( 42 ) =

def f(): return 42

this one is less than 25

kc( 999999999 ) =

int('9'*9) is too big!

nine 9s

kc( 100…000 ) =

100 zeros

Let's estimate the Kolmogorov complexity values of these first four.

kc( 100…000 ) =

a googol zeros

kc( 1010…1010 ) =

2 billion total digits

kc( 31415926… ) =

What about this last one?

2 billion digits of pi

Kolmogorov Complexity

Name(s) ____________________

+2

example

Python has 16 chars of setup

more

18

1

2

3

4

5

6

7

8

9

17

18

10

11

12

13

14

15

16

kc( 42 ) =

def f(): return 42

23 = 16+7

10**9-1

kc( 999999999 ) =

nine 9s

23 = 16+7

10**100

kc( 100…000 ) =

100 zeros

10**10**100

27 = 16+11

kc( 100…000 ) =

a googol zeros

31 = 16+10

int('10'*10**9)

kc( 1010…1010 ) =

2 billion total digits

< 200

kc( 31415926… ) =

use your pi-estimating program!

2 billion digits of pi

Althoughkc(x) has a well-defined output for every integer inputx,

kc(x)

is not a computable function.

what does this mean?

Althoughkc(x) has a well-defined output for every integer inputx,

kc(x)

is not a computable function.

This means every implementation of kc(x) contains a bug!

provably!

(1) Consider a possible program for kc(x):

Try it on 42!

defkc( x ):

return x/2 - 3

The correct complexity of 10 is 18.

But kc(10) outputs 2, not 18.

That's a bug!

(2) Find a bug:

(1) Consider a possible program for kc(x):

Try it on 42!

defkc( x ):

return x/2 - 3

The challenge: we have to find a bug in any possible version of kc(x)!

The correct complexity of 10 is 18.

But kc(10) outputs 2, not 18.

That's a bug!

(2) Find a bug:

(1) Consider any possible kc(x):

defkc( x ):

do stuff…

return answer

I guess you'd call this part of the code a GRAY AREA…

???

(2) Find a bug:

defkc( x ):

do stuff…

return answer

Let's presume that this version of kc is 42,000 characters long…

Proof steps:

#0:

defBFF():

x = 0

whilekc(x) <= 50000:

x += 1

return x

Does BFF's while loop ever stop?

Will that while loop stop

when x is less than 50,000,

when x is equal to 50,000,

when x is greater than 50,000,

or never… ?

#1:

Does every integer x have kc(x) <= 50000?

or, do there exist integers x with kc(x) > 50000?

defkc( x ):

do stuff…

return answer

Let's presume that this version of kc is 42,000 characters long…

defBFF():

x = 0

whilekc(x) <= 50000:

x += 1

return x

Steps

#2:

Try completing this thought: BOOM returns the smallest integer whose complexity is

______________________________________ .

bug = BFF()

The complexity of an integer is the length of the shortest zero-input function that returns that integer…

defkc( x ):

do stuff…

return answer

Let's presume that this version of kc is 42,000 characters long…

defBFF():

x = 0

whilekc(x) <= 50000:

x += 1

return x

Steps

#3:

Why is this a problem? Hint: how many characters of code are on this slide – including the 42,000 in kc?!

bug = BFF()

kc( bug )

The complexity of an integer is the length of the shortest zero-input function that returns that integer…

defkc( x ):

do stuff…

return answer

Let's presume that this version of kc is 42,000 characters long…

defBFF():

x = 0

whilekc(x) <= 50000:

x += 1

return x

Steps

#3:

Why is this a problem? Hint: how many characters of code are on this slide – including the 42,000 in kc?!

BFFreturns an int with complexity >50,000 using only 42,100 characters!

bug = BFF()

kc( bug )

The complexity of an integer is the length of the shortest zero-input function that returns that integer…

Although kc(x)has a well-defined output for every integer input x,

kc(x)

is not a computable function.

Every implementation of kc(x) contains a bug!

proven!

The best-compressed version of any data D is the shortest program that generates D.

Which text has been compressed here?

The best-compressed version of any data D is the shortest program that generates D.

Which text has been compressed here?

The best-compressed version of any data D is the shortest program that generates D.

best-compressed data?

Uncomputable!

How about this approach to computing kc(x)

Wait! What about this:

There are only finitely many programs to check in order to find the shortest one that returns x!

fewer than 12816+x of them

- The correct program is at most 16+x characters long.

- Check all, shortest to longest, to see which returns x.

- The first one to return x is the shortest. You're finished!

Is there a bug here? Or in our proof?

How about this approach to computing kc(x)

Wait! What about this:

There are only finitely many programs to check in order to find the shortest one that returns x!

fewer than 12816+x of them

- The correct program is at most 16+x characters long.

- Check all, shortest to longest, to see which returns x.

- The first one to return x is the shortest. You're finished!

Checking programs is also uncomputable!

What - how!?!

Halt Checking

hc( f)

~ returns whether f()halts or not

hc can't be written well, not without bugs

Any Python function

defhc( f ):

It is impossible to write a bug-free function hc(f)that determines if function f halts when run, that is,

(1) hc(f)returns True if f()halts and

(2) hc(f) returns False if f()loops infinitely

Proof!

Suppose hc(f) works…

Then write this f'n, CANT

defCANT():

ifhc(CANT):

whileTrue: print'Ha!'

else:

return 42

True?

What is hc(CANT)

False?

Good luck with final projects!

They will halt all too soon!!

Tutoring hours and labs through the week…

even with ∞ memory!

Uncomputablefunctions?

well-defined computational problems

computer program

There are

that no

even with ∞ memory!

Uncomputablefunctions?

well-defined computational problems

computer program

There are

that no

defis_even(x):

return x%2 == 0

CS 5 homework

Video

games

Pico-

bot

Int-bool functions

defis_three(x):

return x == 3

Team Fortress

Well-defined computational tasks

Programs

These programs are both int-bool functions

even with ∞ memory!

Uncomputablefunctions?

well-defined computational problems

computer program

There are

that no

There are more of these …

CS 5 homework

defis_even(x):

return x%2 == 0

than these!

Video

games

Pico-

bot

Int-bool functions

Team Fortress

Well-defined computational tasks

Programs

These programs are both int-bool functions

Your springtime state machine!

May

final classes!

final exams!

April

summer…

this arrow holds a LOT of stuff!

An unusual variation on VPool

Have a relaxing long weekend!

… the graders certainly do!

text cloud

this doesn't look nearly colorful enough…

Summary of the words in a body of text, sized according to their frequency.

Input

http://www.cs.hmc.edu/~cs5grad/cs5/textcloud/page1.html

http://www.cs.hmc.edu/~cs5grad/cs5/textcloud/textcloud.html

Hey! Where did these come from?

Output

I think spam should go to 11!

http://www.cs.hmc.edu/~cs5grad/cs5/textcloud/page1.html

Spamming spammers spammed spam. Spam spam spam! I love spam!

['spamming', 'spammers', spammed', 'spam.', 'spam', 'spam', 'spam!',

'I', 'love', 'spam!', 'page', '2']

What happened here?

['spamming', 'spammers', spammed', 'spam', 'spam', 'spam', 'spam',

'love', 'spam', 'page', '2']

And here?

['spam', 'spam', spam', 'spam', 'spam', 'spam', 'spam',

'love', 'spam', 'page', '2']

What's next?

From text…

- Start with text…
- Split it into words…
- With the list of words
- Clean the words
- Stem the words
- Count the words
- Return a string with frequencies
- Add advanced features…

This looks familiar...

So does this!

… to cloud

What is a word for which each of these rules "works" and "fails." Then, add a new rule that handles one of the failures – or an entirely new case!

defstem( w ):

if w[-3:] == 'ing':

w = w[:-4]

Stemming

This works for

it fails for _________

elifw[-3:] == 'ies':

w = w[:-3] + 'y'

This works for _________

it fails for _________

elifw[-2:] == 'er':

w = w[:-3]

This works for _________

it fails for _________

Write a rule to handle plurals ...

(1) What might go wrong?

(2) How might you fix it?

return w

It's easy to miss cases!

Develop the basic text-processing in Python+IDLE.

After that works, use a webpage to deploy it...

First:

Then:

- Use the provided code to read HTML + process the results into ordered lists of words…

- Once you have things working, move on to
- writing HTML
- following links beyond depth 1

Building a web crawler ...

Finally:

What will you need to look out for?

- Personalize - There are lots of ways to do this!

http://chir.ag/phernalia/preztags/

Robots typically cycle through several states :

States represent current subtasks

other keys...

Arrows represent transitions, through sensor or keybd feedback

FWD

KBD

's' key pressed

go forward

keyboard control

This triangle indicates the "start state"

How do we get out of FWD?

"a finite state machine"

Final project:1 Euro for each deadline

as long as one partner has a Euro left....

Also ask about our Euro "buy-back" plan: convert your unused Euros to more valuable currency (like M&Ms)

Getting familiar with VPython's API...

(0) How many tuples appear in this code? ________

(1) How many classes are used here? ________

(2) How many objects are used here? ________

(3) How are the collisions working?

Look over this VPython program to determine

from visual import *

floor = box( pos=(0,0,0), length=4, height=0.5,

width=4, color=color.blue)

ball = sphere( pos=(0,4,0), radius=1, color=color.red)

ball.velocity = vector(0,-1,0)

dt = 0.01

whileTrue:

rate(100)

ball.pos = ball.pos + ball.velocity*dt

if ball.pos.y < ball.radius:

ball.velocity.y = -ball.velocity.y

else:

ball.velocity.y = ball.velocity.y - 9.8*dt

What's this if/else doing?

What is a word for which each of these rules "works" and "fails." Then, add a new rule that handles one of the failures – or an entirely new case!

def stem( wd ):

if wd[-3:] == 'ing':

wd = wd[:-3]

This works for _________

it fails for _________

elif wd[-3:] == 'ies':

wd = wd[:-3] + 'y'

This works for _________

it fails for _________

elif wd[-2:] == 'er':

wd = wd[:-3]

This works for _________

it fails for _________

Write a rule to handle plurals ...

(1) What might go wrong?

(2) How might you fix it?

return wd

It's easy to miss cases!

I guess I'll watch out for VPython collisions...!

from visual import *

wall = box( ... )

ball = sphere( pos=(10,0,0), radius=1 )

ball.velocity = vector(-2,0,0)

RATE = 30

dt = 1/RATE

whileTrue:

rate(RATE)

ball.pos += ball.velocity * dt

if ball.pos.x < 2.0:

print "Collide!"

ball.velocity = -ball.velocity

Start...

this is x == 2

Stuck!

What errors – in coding or logic or both – are here?

I guess I'll watch out for VPython collisions...!

vPoolcollisions

from visual import *

wall = box( ... )

ball = sphere( pos=(10,0,0), radius=1 )

ball.velocity = vector(-2,0,0)

RATE = 30

dt = 1/RATE

whileTrue:

rate(RATE)

ball.pos += ball.velocity * dt

if ball.pos.x < 2.0:

print "Collide!"

ball.velocity = -ball.velocity

Start...

this is x == 2

Stuck!

What errors – in coding or logic or both – are here?

(this week is VPython)

December's labs are final-project based:

- optional, but helpful! (even more optional than usual...)

- a natural opportunity to work in a pair

- work on your laptop or the CS machines

- easy access to help

and some of the CS machines do need work!

- unspeakably fun!

Don't say it!

transition on 0

transition on 0

transition on 1

State 1

State 0

transition on 1

0010111

What does each state MEAN ?

an input sequence

What does this FSM do overall?

always left-to-right

0

1

s1

1

s0

0

s2

0,1

Specifically?

What inputs does this FSM accept?

Generally?

Fewer states?

What does each state MEAN ?

Hey! Watch where you're going!

Pt A

How do I control this robot !?!

2d simulator

Goal: get from Pt A to Pt B

Pt B

Robot control continuously loops through three things:

whileTrue:

SENSE

PLAN

ACT

Sounds refreshing to me!

Robots almost always use the SPA approach!

Robots typically cycle through several states :

States represent current subtasks

other keys...

Arrows represent transitions, through sensor or keybd feedback

FWD

KBD

's' key pressed

go forward

keyboard control

This triangle indicates the "start state"

How do we get out of FWD?

"a finite state machine"

Robots typically cycle through several states :

States represent current subtasks

other keys...

Arrows represent transitions, through sensor or keybd feedback

FWD

KBD

's' key pressed

go forward

keyboard control

This triangle indicates the "start state"

How do we get out of FWD?

"a two-state state machine"

What is a word for which each of these rules "works" and "fails." Then, add a new rule that handles one of the failures – or an entirely new case!

def stem( wd ):

if wd[-3:] == 'ing':

wd = wd[:-3]

This works for _________

it fails for _________

elif wd[-3:] == 'ies':

wd = wd[:-3] + 'y'

This works for _________

it fails for _________

elif wd[-5:] == 'ement':

wd = wd[:-4]

This works for _________

it fails for _________

Fix one of these rules – or write another one... .

return wd

Maybe stemming stemming?

Your simulator will be able to run these rules just like any others!

Previously cool submissions...

You mean these no longer qualify as cool?

http://stanford.edu/~ccecka/research/C4.html

Creativity + Physics = vPool !

The pyRobot project ~ additions

Goal: get from Pt A to Pt B

Main

Optional

Start in an unknown location on the map…

Implement a niftier interface…

vPython Robot?

I'm lost!

Use only the bump sensors… (no range sensing)

Use noisy (realistic) data

The pyRobot project ~ additions

Goal: get from Pt A to Pt B

Main

Optional

Start in an unknown location on the map…

Implement a niftier interface…

vPython Robot?

I'm found!

Use only the bump sensors… (no range sensing)

Use noisy (realistic) data

Try your code for a "spin"…

Thanks, Alex!

pwd

ls

cd

nano

cp

chmod

wc

prints the current directory

lists the current directory

changes directory

edits files

copies files

changes file permissions

Hey - that's me!

counts the words, lines, and characters

Design for software and beyond

Don Norman's key principles:

0. Conceptual models

1. Mapping

Visibility

Feedback

Affordances

Mapping

Visibility

Feedback

Affordances

Set to 5 minutes?

How to open this gas cap?

This handle unfastens the seat from the floor.

Win NT Dialog

How to turn on this stove?

(0,0,0)

(220,205,0)

(110,102,0)

CS 5's winter weeks:

final project

computational models

uncomputability

No regular labs this week

Ex. Cr. labs are scheduled

Tue. (today): 2:45-4:45

Tue., 12/14 2 pm –Exam option #1

Wed. (tomorrow): 2:45-4:45

Thu., 12/16 9 am –Exam option #2

more later on, too ...

congratulations to all E11ers!

- Today is about the CS 5 Term Projects
- Sales pitch for the four possible options...
- A sneak peek at "December in CS 5"

vPool

Picobot

pyRobot

Text Clouds

I’ve got my eyes on some of these projects!

Eye'll bet!

open-ended

comprehensive

Final CS assignment

same projects for black/gold

several choices…

Working solo or duo is OK

Pairs need to work together (in the same place) and to share the work equally...

Eye, eye!

Phunky Fisicks is welcome!

VPython was designed to make 3d physics simulations simpler to program

Collisions with walls should be handled...

Collisions with other pool balls should be handled...

Pockets – or some other game objective

A few examples to get you thinking…

Linux users are welcome!

But they should use another OS…

Input

http://www.cs.hmc.edu/~cs5grad/cs5/textcloud/page1.html

http://www.cs.hmc.edu/~akeizur/

Hey! Where did these come from?

Output

I think spam should go to 11!

http://www.cs.hmc.edu/~cs5grad/cs5/textcloud/page1.html

Spamming spammers spammed spam. Spam spam spam! I love spam!

['spamming', 'spammers', spammed', 'spam.', 'spam', 'spam', 'spam!',

'I', 'love', 'spam!', 'page', '2']

What happened here?

['spamming', 'spammers', spammed', 'spam', 'spam', 'spam', 'spam',

'love', 'spam', 'page', '2']

And here?

['spam', 'spam', spam', 'spam', 'spam', 'spam', 'spam',

'love', 'spam', 'page', '2']

What's next?

From text…

- Start with a webpage (URL)
- Read in text
- Create a list of words
- Clean the words
- Stem the words
- Count the words
- Return a string with frequencies
- Add advanced features…

This looks familiar...

So does this!

… to cloud

Develop the basic application using IDLE.

After it works, make it a webpage...

The Approach:

- Use the provided code to read HTML

- Make sure that you can process the files appropriately into ordered lists of words…

- Once you have things working, move on to
- writing HTML
- following links beyond depth 1

Building a web crawler ...

What will you need to look out for?

- Once you have everything working,
- transfer your files to your webspace.
- set up the HTML wrapper files & go…

- Personalize - There are lots of ways to do this!

Alexa's ...

http://chir.ag/phernalia/preztags/

Robots typically cycle through several states :

States represent current subtasks

other keys...

Arrows represent transitions, through sensor or keybd feedback

FWD

KBD

's' key pressed

go forward

keyboard control

This triangle indicates the "start state"

How do we get out of FWD?

"a two-state state machine"

Robots typically cycle through several states :

other keys...

FWD

KBD

's' key pressed

go forward

keyboard control

Finish drawing the state machine for the random robot...

Robot control continuously runsthree things:

whileTrue:

SENSE

PLAN

ACT

[x,y,thd], bump = self.getData()

if bump[0] == Trueor bump[1] == True:

print'BUMP!',

print' [Left bump sensor:', bump[0], '] ',

print' [Right bump sensor:', bump[1], '] '

robotTask = STOP

STOP is one of the robot's states. Every 40th of a second, the robot runs through this loop, sets the robot's state and sets the velocities accordingly. Don't sleep!

if robotTask == STOP:

self.setVels(0,0)

robotTask = KBD

Picobot is also a finite-state machine!

Basic idea: implement Picobot (the hw problem from Week 1)

talk about full circle...

Picobot is also a finite-state machine!

Basic idea: implement Picobot (the hw problem from Week 1)

Requirements:

Text and graphical output

Read Picobot program from a file

Read maze description from a file

Keep track of visited/unvisited squares

Prohibit illegal moves – unless they're legal...

What data structures (classes) might be helpful in implementing Picobot?

Current State: 1

Current Rule: 1 N*W* -> X 2

++++++++++

+o++o+o+++

+oooooo ++

++++o++ +

+oooo+++++

++++o +

+oooo+++ +

++++o+++++

+Rooo +

++++++++++

First, prototype it as ASCII-bot

Picobot started here…

and is now here…

turtle version…

Graphical picobot:

- Choice of graphical packages
- VPython for 3d
- turtle for 2d
- Start/stop/step feature
- Maze editing
- Pebble dropping
- Be inventive!

Lots of options…

Mon., 12/6 – Interim milestones due (11:59 pm)

milestone.txt

milestone.py

- Name(s)
- Project chosen
- Your project description:
- What is your plan.
- What is your approach.
- A start at an implementation.

- Classes and functions
- Docstrings
- 60-80+ lines of working, tested code

It’s actually a kilometer stone.

Nice milestone!

Fri., 12/10 – Final deliverables due (by 5:00 pm)

final.txt

final.py

- Name(s)
- Project chosen
- Description of user interface:
- How do we run / play your project.
- What features did you implement.
- What was your approach & plan.

- Classes and functions with documentation/docstrings
- Working, tested code

A final milestone?

Final project:1 Euro for each deadline

as long as one partner has a Euro left....

Ask Prof. Ran about his Euro "buy-back" plan!

December's labs are final-project based:

- optional, but helpful!

- a natural opportunity to work in a pair

and some of the CS machines do need work!

- work on your laptop or the CS machines

- easy access to help

- HTML set up for the TextClouds project

- unspeakably fun!

Don't say it!

optional labs?

(0,0,0)

(220,205,0)

(110,102,0)

CS 5's final three weeks:

final project

w/Euro

CS labs this week: VPython

25

CS hwk this week: C4 AI

Hwk 11 due: Dec. 3

Mon., 12/17 2 pm –Exam option #1

final exam

Wed., 12/19 9 am –Exam option #2

""" MUST return a list of 7 scores!! """

scores = [50,50,50,50,50,50,50]

(0) Start all scores at 50.

(1) For each col to move:

(2a) If not possible…

(2b) If game already over…

(2c) Else add the move to b

(3) Ask an opponent (!!!) for its scoresFor at ply-1

(4) compute self's score

forcolin range( 0, 7 ):

returnscores

Download Presentation

Connecting to Server..