Presentation is loading. Please wait.

Presentation is loading. Please wait.

AS Computer Studies Finite State Machines 2.

Similar presentations


Presentation on theme: "AS Computer Studies Finite State Machines 2."— Presentation transcript:

1 AS Computer Studies Finite State Machines 2

2 Starter Let’s play the Finite State Pirates Game REQUIRES Teacher Prep

3 Objectives Understand the stages of problem solving.
Become familiar with finite state machines and their purpose. Be able to create and construct a state transition table Be able to construct a decision table

4 Recap A volunteer: Talk through this state transition diagram. 1, B
Start 0, A State1 1, B State2 2, !

5 Recap: Light Switch as a table
State Transitions are one way of describing a finite state machine. Another way is a State Transition Table. It shows what states a FSM will move to based on the current state and other inputs. (Note there are NO outputs) State 0 State 1 Light-switch Down Light-switch Up Input Current State (S0) Next State (S1) Turn Switch On Light switched off Light switched on Turn Switch Off Light Switched on Light Switched off

6 Quick Task: Creating a State Transition Table (PRINT)
Input Current State Output Next State S0 A 1 B S1 2 Try and complete the State Transition Table State 0 Start 0, A State1 1, B State2 2, !

7 Create your own State Transition Table
Complete this State Transition Table based on the briefcase FSM. Note, there are NO outputs. <> = not Input Current State Next State <> 2 S0 (locked) S0 (Locked) 2 S1 (First) <> 4 4 S2 (Second) <> 9 9 S3 (Unlocked) Input Current State Next State <> 2 2 <> 4 4 <> 9 9

8 Decision Tables When solving logical problems there can be A LOT going on. How do make sure that everything is accounted for? You use a Decision Table! – Show the outcomes for a given logical condition. Can you work out what each condition shows: condition alternatives conditions actions action entries

9 Steps to making a decision table
Draw boxes for the top and bottom left quadrants. List the conditions in the top, left quadrant.  When possible, phrase the conditions as questions that can be answered with Yes or No. (You may need to figure these out first)  List the possible actions in the bottom, left quadrant. (You may need to figure these out first) Each condition can have Y or N values (so, 2 in total). Multiple the number of conditions by the number of possible values (2). Draw one column through the top and bottom right quadrants for each combination. For example, if there are three conditions then it would be 3*2 = 6 possible columns. 5. Enter all possible combinations of values in the columns in the top, right quadrant of the table. 6. For each column (each unique combination of conditions), mark an X in the bottom, right quadrant in the appropriate action row

10 Whole Class Work through
Let’s draw it together. We will work out a solution If it is a weekday go to work, even if its raining. If it’s a holiday, don’t go to work. If it’s a holiday and it’s not raining, go on a picnic. If it’s a holiday and it’s raining, relax and watch TV. What are the rules / conditions? How many condition alternatives will there be? (multiply the number of possible alternative values together. E.g. Y/N = 2 values. If there were 4 conditions it would be 2*2*2*2 – multiplying the number of rule values together, giving 16 conditions). What are the actions?

11 The Decision Completed Table

12 Practice Tasks Now it’s your turn to have a go.
Work through the printed activities: Decision Table Exercises Teacher Answers We will step through them. Need help? Look at examples in your text book.


Download ppt "AS Computer Studies Finite State Machines 2."

Similar presentations


Ads by Google