Presentation is loading. Please wait.

Presentation is loading. Please wait.

BPC: Art and Computation – Summer 2007 Computer Programming with Logo Glenn Bresnahan

Similar presentations


Presentation on theme: "BPC: Art and Computation – Summer 2007 Computer Programming with Logo Glenn Bresnahan"— Presentation transcript:

1 BPC: Art and Computation – Summer 2007 Computer Programming with Logo Glenn Bresnahan glenn@bu.edu

2 BPC: Art and Computation – Summer 20072 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 http://scv.bu.edu/BPC/MaterialsSpring07/lectures/BPC -Class-LogoNotes.doc (to be provided) Example programs (to be provided) http://scv.bu.edu/BPC/MaterialsSpring07/aux/Logo/

3 BPC: Art and Computation – Summer 20073 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

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

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

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

7 BPC: Art and Computation – Summer 20077 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

8 BPC: Art and Computation – Summer 20078 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

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

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

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

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

13 BPC: Art and Computation – Summer 200713 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

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

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

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


Download ppt "BPC: Art and Computation – Summer 2007 Computer Programming with Logo Glenn Bresnahan"

Similar presentations


Ads by Google