computer programming with logo l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Computer Programming with Logo PowerPoint Presentation
Download Presentation
Computer Programming with Logo

Loading in 2 Seconds...

play fullscreen
1 / 16

Computer Programming with Logo - PowerPoint PPT Presentation


  • 290 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Computer Programming with Logo' - DoraAna


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
computer programming with logo

Computer Programming with Logo

Glenn Bresnahan

glenn@bu.edu

synopsis
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

programming constructs
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

using logo
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

concepts
Concepts
  • Computers and stored programs
  • Procedures/algorithms
    • Analogies to cooking/recipes
  • Programming languages
  • Logo history/background

BPC: Art and Computation – Summer 2007

logo language
Logo Language
  • Logo words
  • Verbs and nouns
  • Commands/imperatives
  • Inputs
  • Functions (procedures that ouput)
  • Numbers and arithmetic

BPC: Art and Computation – Summer 2007

turtle graphics
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

variables
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

words and lists
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

numerical computing
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

conditionals
Conditionals
  • if statements
    • Testing for conditions
    • Comparison operators
    • Logical operators

BPC: Art and Computation – Summer 2007

daffie agents turtle3d
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

daffie robot
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

hunting algorithm random
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

hunting algorithm binary search
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

hunting algorithm binary search16
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