10TopDownDesign

10TopDownDesign - – Spin roverbot to face the darkest direction Steps Main Collect Readings Seek Darkest Spin Left Pseudo Code for Main Task 1

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Top Down Design COMP106 Approaching a Complex Problem • Many problems require multiple steps to solve. • Need to break down the problem into manageable pieces. • Top-down design technique.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Top Down Design • Most natural way to approach a problem. • First, break down the problem into logical, independent “chunks” - components. • If each component is still very complex, break it down into smaller component. • 7±2 components per level. Example • Write an NQC program that allows your roverbot to turn to the direction that is darkest. This involves three major steps as described below: – Collect light sensor readings from 8 compass directions. – Find the direction that is darkest.
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: – Spin roverbot to face the darkest direction. Steps Main Collect Readings Seek Darkest Spin Left Pseudo Code for Main Task 1. Collect readings 2. Seek darkest Pseudo Code for “Collect Readings” 1. SET counter TO 0 2. SET position TO 0 3. SET darkest TO light_sensor 4. WHILE( counter < 8 ) 4.1. increment counter 4.2 TURN 22.5 degrees left 4.3 IF light_sensor < darkest THEN 4.3.1 SET darkest TO light_sensor 4.3.2 SET position TO counter 4.4 ENDIF 5. ENDREPEAT Pseudo Code for "Seek Darkest" 1. spin left for (position number * time to spin to next position) Steps Main Collect Readings Seek Darkest Spin Left p o s i t n length...
View Full Document

This note was uploaded on 09/16/2010 for the course COMP 106 taught by Professor Jasonmadar during the Fall '07 term at Capilano.

Page1 / 5

10TopDownDesign - – Spin roverbot to face the darkest direction Steps Main Collect Readings Seek Darkest Spin Left Pseudo Code for Main Task 1

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online