Lesson Plan 18

Logo Programming

 

Lesson Title

Logo Programming

Duration

9 classes (13.5 hours)

Synopsis

This segment introduces students to computer programming using the Logo programming language. The students are introduced to the concepts of algorithms, computer programs and programming languages. The students learn the principles of variables, iteration, conditionals, arithmetic operations, procedures and parameters and use these constructs in writing programs. Logo’s Turtle Graphics are used to introduce the students to 2D computer graphics. These concepts are extended to allow the students to write Logo programs which control robotic-like objects in a 3D virtual world. The students are introduced to string operations using Logo’s words and data structures using Logo’s lists.

Description of Class

This segment consists of a series of classes in which the students learn the concepts of computer programming using Logo. The class starts by using Logo’s turtle graphics to draw a simple 2D graphics pattern (a motif) and then uses the concepts of procedures and iteration to create simple tiling (repeating) patterns based on the motif. The concepts learned in using Logo’s turtle graphics are later applied to moving objects in a 3D virtual world using Turtle3D, a set of extensions to Logo which allow it to manipulate 3D objects, in this case a 3D model of a turtle, in a DAFFIE virtual world. The concepts of variables, functions and conditionals are introduced. These concepts are used to program a robotic-like search algorithm.

 

In the first class the concepts of programming and programming languages are introduced using parallels between computer programming languages and natural languages and the analogy between an algorithm and a cooking recipe. Simple Logo turtle commands are introduced and demonstrated. The students are asked to construct a list of commands to draw an interesting pattern.

 

The notion of procedures is introduced and the students construct a procedure consisting of the turtle commands used to draw their pattern. The mechanisms for editing, saving and loading the Logo workspace (procedure definitions) are demonstrated and practiced.

 

The notion of variables is introduced. It is shown how a variable can be used to alter the behavior of a procedure, e.g. drawing a different sized pattern depending on the value of the variable. This segues to the concept of procedures with formal parameters, i.e. procedures which take inputs/arguments. The notion of scoping is briefly introduced.

 

The next segment explores data structures and numerical computing.

Operations on words (strings) are introduced. Lists structures and operations which act on them are covered. Arithmetic and trigonometric operations are introduced. The trig functions are motivated by the problem of determining the turtles heading and forward motion required to move to a given coordinate.

 
In the next segment the idea of conditionals, i.e. if, is introduced. These are coupled with iteration, i.e. the while statement, to construct more complicated control structures. Using iteration and conditionals allows the idea of algorithm to be more fully developed. [Although it was not done in the class, flowcharts might be helpful in teaching these concepts].

 

In the last segment, the Turtle3d commands, a set of Logo functions provided with the BU variant of UCB-Logo, are covered. These allow the students to control objects in the 3D virtual space. All of the above mechanisms are combined to develop a program to have the 3D turtle search for “food” in the virtual world.

Primary Educational Objective

Computer programming

Computer procedures and functions

Variables and parameters

Iteration

Conditionals

2D computer graphics

3D coordinates and transformations

Elementary robotics

Additional Concepts and Skills

 

Assessment

The students are asked to write a number of programs which use the concepts taught in the classes. This are used to evaluate their mastery of the materials.

Classroom Activities

These materials are covered using a combination of lecture and demonstrations with student hands-on activities. An effective approach is for the instructor to display a live Logo session as well as the lecture notes, so the various Logo operations can be demonstrated.  The students then use their workstations to apply the materials and gain hands-on experience. The class times are roughly equally split between presentations and hands-on. Each third class is designated as a lab for students to work on the programming assignments with assistance from the instructional staff.

Homework Assignments

  1. Create a simple pattern on the display using “turtle graphics”
  2. Create and save a procedure which draws a simple pattern and returns the turtle to the starting position
  3. Using the procedures defined in the previous exercise along with iteration, write procedures to fill the screen with your pattern.
  4.  Write a program using the Turtle3D routines to search for “food” in the DAFFIE virtual world using the smellfood procedure which has been provided for you.  The smellfood procedure returns a number from 1 to 1000 indicating how close your turtle is to the food, the higher the number the closer you are to the food.

Lecture Materials

Lecture materials are available as a Power Point presentation

Reference Materials

Logo Users Manual

http://el.media.mit.edu/logo-foundation/index.html

http://www.israelsson.org/~lethe/logobook/0.5.1/lets_learn_logo.html

http://http.cs.berkeley.edu/~bh/v1-toc2.html

Prerequisites (this course)

 

Related Topics

Cartesian coordinates in 2 and 3 dimesions

Plane geometry

Trigonometry

Patterns and tiling

Symmetry groups

Technology Requirements

Workstations

UCB Logo with Boston U niversity extensions (Turtle3d)

DAFFIE with Turtle World virtual environment

Comments

This section of the course required more time than was allotted. We would recommend at least another week for students who have had no prior exposure to programming concepts. The concept of variable was particular problematic for the students and adding an exercise specifically to reinforce this idea is strongly recommended. The search algorithm introduced for the last exercise may also be too complex.

 

It is easy to imagine that these materials could be expanded into a full semester course which thoroughly covered the Logo language and programming concepts and then used Logo as the primary mechanism to build and manipulate a virtual world.