120 likes | 138 Views
AS Computer Studies. Finite State Machines 2. Starter. Let’s play the Finite State Pirates Game REQUIRES Teacher Prep. Objectives. Understand the stages of problem solving. Become familiar with finite state machines and their purpose.
E N D
AS Computer Studies Finite State Machines 2
Starter • Let’s play the Finite State Pirates Game • REQUIRES Teacher Prep
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
Recap • A volunteer: Talk through this state transition diagram. 1, B State1 1, B Start 0, A State 0 0, A State2 2, ! 2, !
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) Light-switch Down State 0 State 1 Light-switch Up
Quick Task: Creating a State Transition Table (PRINT) Try and complete the State Transition Table 1, B State1 1, B Start 0, A State 0 0, A State2 2, ! 2, !
Create your own State Transition Table S3 S1 S2 S0 Complete this State Transition Table based on the briefcase FSM. Note, there are NO outputs. <> = not
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
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
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?
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.