Top Banner
04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University 1
15

04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Dec 16, 2015

Download

Documents

Marilynn Parks
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

04/18/13

State Diagrams

Discrete Structures (CS 173)Derek Hoiem, University of Illinois 1

Page 2: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

State diagrams• Model set of valid actions and their effect on “world” state

– Nodes represent states– Edges indicate that it is possible to transition from one state to

another– Labels on edges indicate how to transition

• Many applications– Simple electronics– Games, e.g., AI controls– Probabilities over multiple turns– Probabilistic inference for multiple variables (e.g., handwriting

recognition)– Planning in robotics

2

Page 3: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

State diagrams

3

state

action

transition

Transition function:

Page 4: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Simple example: traffic signal

4

Page 5: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Transition functions and state diagrams

States: Village, Rock, Snake, Chasm, Gold, DesertTransitions: (Village, North) Desert(Village, East) Snake(Desert, South) Village(Desert, East) Rock(Rock, West) Desert(Snake, West)Village(Snake, East) Chasm(Snake, South) Gold(Gold, North)Snake

5

Page 6: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Transition functions and state diagrams

6

Adventures in Serenia

Input sequence to beat the game: N, E, E, E, E, N, E, N, W, GET ROCK, N, W, N, W, N, W, N, THROW ROCK, N, DRINK WATER, E, GET STICK, THROW STICK, W, N, THROW STICK, LOOK HOLE, GET NOTE, N, W, LIFT ROCK, N, GET NOTE, E, GET LOCKET, E, E, S, W, W, LOOK HOLE, GET CRACKER, E, N, N, W, N, W, N, SAY HOCUS, N, GO HOUSE, GET APPLE, W, N, LOOK GNOME, N, E, SAY HISS, GO CREVICE, S, S, S, GET BREAD, GET LOCKET, GET CRACKER, UNLOCK DOOR, OPEN DOOR, GO DOOR, U, GO HOLE, N, E, S, GIVE CRACKER, GET VIAL, N, W, S, W, W, THROW BREAD, N, GET ROPE, GO BOAT USE BLANKET, N, N, DRINK WATER, N, E, E, E, GO BEACH, N, N, E, GET ANCHOR, W, TIE ROPE, TO ANCHOR, THROW ANCHOR, UP, GET SHOVEL, DOWN, S, S, DIG X, LOOK TREASURE, GRAB CHEST, LEAVE, E, N, W, GO CAVE, OPEN CHEST, LOOK CHEST, GET HARP, N, E, N, DRINK VIAL, FLY NORTH, N, GET RING, N, W, FOLLOW RAINBOW, GET COIN, N, SAY LUCY, W, W, N, GO CAVE, GET ALL, N, S, W, PLAY HARP, N, N, BUY HORN, N, N, BLOW HORN, N, U, E, OPEN CLOSET, LOOK CLOSET, GET SHOES, LOOK SHOES, W, D, W, W, LOOK THRONE, THROW APPLE, N, E, LOOK CABINET, PICK LOCK, WITH KNIFE, OPEN DOOR, E, U, D, U, WEAR RING, RUB RING, D, E, KISS FROG, WEAR SHOES, SAY WHOOSH

Page 7: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Making a NAND diagram

7

Page 8: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Frogger

Strategy to cross road

8

Page 9: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Handwriting recognition

9

Page 10: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Handwriting recognition

10

Page 11: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Suppose we roll a two-sided die until the sum is a non-zero multiple of 3. What is the chance of getting there in three or fewer rolls?

12

Page 12: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Dice gamesWhat is the chance of rolling snake eyes (double ones) in one roll of two six-sided dice?

If I am allowed to re-roll, what is the probability of getting 1-1?

If I have dice and a person is trying to as many ones as possible in rolls, what is the computational complexity of calculating the odds of each outcome?

13

Page 13: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Challenge problemIf Joe is going for “Yahtzee” (five of a kind with five dice), what is the chance that he will get it within two re-rolls?

14

Page 14: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

In poker, how often will an A-7 hand beat a 2-2 hand if cards are drawn?(assume only highest pairs, triples, four-of-a-kind can win)

15

Page 15: 04/18/13 State Diagrams Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Things to remember• State diagrams model how state changes with

actions– Useful for modeling sequences of events, complex

probabilistic outcomes, planning, automation, etc.– Especially useful when states can be visited more than

once

16