1 / 16

Computer Programming with Logo

Computer Programming with Logo. Glenn Bresnahan glenn@bu.edu. Synopsis. Introduction to computer programming and the Logo programming language Concepts of programming, computer languages and algorithms Programming constructs Combination of lecture and hands-on labs

kenaz
Download Presentation

Computer Programming with Logo

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Programming with Logo Glenn Bresnahan glenn@bu.edu

  2. Synopsis • Introduction to computer programming and the Logo programming language • Concepts of programming, computer languages and algorithms • Programming constructs • Combination of lecture and hands-on labs http://scv.bu.edu/BPC/MaterialsSpring07/lectures/BPC-Class-LogoNotes.doc • Example programs(to be provided) http://scv.bu.edu/BPC/MaterialsSpring07/aux/Logo/ BPC: Art and Computation – Summer 2007

  3. Programming Constructs • Procedures • Arithmetic operations and math functions • Variables (naming) • Iteration • Recursion • Conditionals and logical operations • Parameters and scoping • Data structures • words (i.e.strings) • lists BPC: Art and Computation – Summer 2007

  4. Using Logo • Computer generate images • Turtle graphics • Patterns and design • 2D Animation • Animated patterns and figures • DAFFIE agents • Controlling 3D DAFFIE objects • Turtle3D BPC: Art and Computation – Summer 2007

  5. Concepts • Computers and stored programs • Procedures/algorithms • Analogies to cooking/recipes • Programming languages • Logo history/background BPC: Art and Computation – Summer 2007

  6. Logo Language • Logo words • Verbs and nouns • Commands/imperatives • Inputs • Functions (procedures that ouput) • Numbers and arithmetic BPC: Art and Computation – Summer 2007

  7. Turtle graphics • Using turtle graphics to draw a pattern • Interactive drawing • Defining procedures using to • Saving the pattern • Saving and loading the Logo workspace • Using iteration to draw patterns repeat 4 [ forward 100 right 90] • Drawing polygons and patterns BPC: Art and Computation – Summer 2007

  8. Variables • Using words to name values • “word vs :word • thing “word • Using symbolic names to change the behavior of a procedure • Inputs to procedures • Formal parameters and arguments • Binding • Scoping Recommend exercises to reinforce these concepts BPC: Art and Computation – Summer 2007

  9. Words and Lists • Manipulating words (strings) • word • first, butfirst, last, butlast • Numbers as words • Manipulating lists • list, sentence • first, butfirst, last, butlast • lput, lput BPC: Art and Computation – Summer 2007

  10. Numerical Computing • Arithmetic operations • Trig functions • Using trig to calculate turtle movements • How do I get to point (x,y)? BPC: Art and Computation – Summer 2007

  11. Conditionals • if statements • Testing for conditions • Comparison operators • Logical operators BPC: Art and Computation – Summer 2007

  12. DAFFIE Agents – Turtle3D • Turtle3D - Logo/DAFFIE interface • Control a 3D DAFFIE turtle • Turtle World • General mechanism to manipulate DAFFIE objects • DAFFIE Robots BPC: Art and Computation – Summer 2007

  13. DAFFIE Robot • Searching for food • smellfood returns an indicator of how far away the food is, 1 to 1000 • Strategies • Complete traversal • Traversal patterns • Random walks • Binary search BPC: Art and Computation – Summer 2007

  14. Hunting algorithm - Random to hunt make “steps 1 while [smellfood < 1000] [findfood] print se [Found food at] pos3d end to findfood make "lastsniff smellfood rt3d 90-random 180 fd3d 2 if smellfood < :lastsniff [ rt3d 180 fd3d 4 ] end BPC: Art and Computation – Summer 2007

  15. Hunting algorithm – Binary Search to findfood make "lastsniff smellfood if (:steps = 1) [ find.direction 360] fd3d 2 if smellfood < :lastsniff [ rt3d 180 fd3d 4 find.direction 180] end BPC: Art and Computation – Summer 2007

  16. Hunting algorithm – Binary Search to find.direction :range if (abs :range) < 1.0 [make "food.direction heading3d stop] localmake "alpha 0.25*:range rt3d :alpha fd3d 1 localmake "smell1 smellfood rt3d -(90+:alpha) fd3d 2*sin :alpha rt3d (90-:alpha) localmake "smell2 smellfood if :smell1 > :smell2 [rt3d :alpha+90 fd3d 2*sin :alpha rt3d -(90-:alpha) ] pr (se [now at] heading3d :range) find.direction 0.5*:range end BPC: Art and Computation – Summer 2007

More Related