Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your.

Slides:



Advertisements
Similar presentations
First of all – lets look at the windows you are going to use. At the top you have a toolbar, with all your various tools you can use when customising your.
Advertisements

Logo Lesson 1 TBE Fall 2004 Farah Fisher.
SuperStar Basics Brian Bruderer. Sequence Editors Traditional sequence editors use a large grid to control when channels are turned on and off. This approach.
Computer Science 1000 LOGO I. LOGO a computer programming language, typically used for education an old language (1967) the basics are simple: move a.
Using Logo and Logic Please use speaker notes for additional information!
© red ©
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
Logo Lesson 2 Logo Procedures
Introduction to TouchDevelop
B.A. (Mahayana Studies) Introduction to Computer Science November March Logo (Part 1) An introduction to Logo: drawing, moving,
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Explanation of Web 6, Web 7 and Web 9 at my site Please be sure to bring up the speaker notes for the explanation Intro - Web 6, Web 7 and Web 9.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
LOGO SOFTWARE BY: SAVE 9S. INTRODUCTION Logo is a software that can be found at : Shared area> High School > ICT > take home software > LOGO32. This is.
Getting Started with HTML Please use speaker notes for additional information!
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Scratch Programming Lesson 2 First glance to programming logic.
A SIMPLE COMPUTER LANGUAGE LOGO. LOGO Introduction Logo is the simplest programming language. It.
Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and.
Turtle see, turtle do Lesson 1 – Welcome to LOGO.
1 Turtle Graphics and Math Functions And how you can use them to draw cool pictures!
Introduction to TouchDevelop
MSW Logo By Awin 9s.
Logo For beginners By Dali Matthews 9S What is logo?
An introduction to Logo Mike Warriner Engineering Director, Google Note: This course is not an endorsement of Logo by Google. All views in this document.
Programmming Class Fall 2011 Sobhan Highschool Teacher: M.Taghizadeh.
CONTROL SYSTEMS Control Systems A command is a directive that performs a specific task An argument is a variable that can be used by the function reveiving.
The Hare Raising Experience of Logo in the Classroom
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
Logo Programming Fall 2011 – Session 7 Programming Class Teacher: M. Taghizadeh Sobhan Highschool.
Algorithms Writing instructions in the order they should execute.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
By Liam Lane How To Use MSW LOGO.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Ready, SET, go! By Melissa Dalis Professor Susan Rodger Duke University July 2011.
Copyright 2002, Tony Gauvin, UMFK
Logo for Beginners By Chris 9S.
The top four lines are required if you are coding in XHTML and want to validate. Copy and paste them as the top four lines in the code you are writing.
Our desktop looks similar to what we see here normally. The pictures on the left are called icons. On the next few slides, we’ll play around with the icons.
LOGO For the beginner Made by Rio Narazaki. W HAT I S L OGO ? Logo is a computer programming language used in Education. Logo is very easy to use. The.
Sight Word Practice and big down a come help.
Popcorn Words blue orange eight red purple nine.
Pablo Revelo. Birds: to 3birds pu home pd lt 80 pu fd 250 pd setpensize 2 setpc "white st bird pu bk random 100 bird pu lt 90 fd random 40 bird ht.
Procedures and Variables Control Logo 1. What you will do today  You will make your code more efficient by using procedures  You will create shapes.
Search for it on your computer
LOGO WHAT IS IT? HOW TO USE IT AND HOW USEFUL CAN IT BE?
What is it? How to use it and how useful can it be?
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
Using the Python Turtle
Computer Programming.
Exploring Mathematical Relationships Module 5: Investigation 3
Using Logo to develop logical thinking
LOGO BY Kaotip 9S.
LOGO 32 By: Xenon 9S.
Watch Pete the Cat here:
Sight Word Lists (141 words)
Learning to program with Logo
Algorithms and Flow Charts
Like.
Go to =>
BUSINESS COMMUNICATION SKILLS PRESENTATION SKILLS OF THESIS & PROJECT
What Color is it?.
Institute for Entrepreneurship and Career Development (IECD)
creating a ecosystems model in net logo
Chapter 1 Introducing Small Basic
Presentation transcript:

Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your home computer.

In later slides, we will reduce the number of turtles to 1, but for now it is fun to create patterns with 30 turtles! StarLogo starts with 30 turtles on top of each other in the center of the screen (note that the black portion of the screen where the turtles are is somewhat truncated in this slide).

FD is the command for forward FD is the command for forward. You follow it with a number that specifies how many steps each turtle should move forward. Note that the command can be given in upper or lower case. In this example, I keyed in the command fd 5 in the Turtle Command Center. FD 5 means that each of the turtles moves forward 5 steps. Each of the turtles moved out from the center by 5 commands.

Note again that the command can be given in upper or lower case Note again that the command can be given in upper or lower case. My first command used fd and the next command used FD. What I have done is used the sequence structure - each turtle followed the first command and then the second command. I am issuing commands using the sequence structure - one command after another. I have now told the turtles to move forward another 2 steps. The two commands I have issued are: fd 5 FD 2

Commands (SEQUENCE): fd 5 Pendown is the PD command and penup is the PU command. Pendown means that the turtles draw as they step. PU means they just move. Notice that when we start the pen is up. Commands (SEQUENCE): fd 5 FD 2 PD In this example, I used PD for pen down and then told the turtles to take two steps forward. The result are lines drawn by each of the 30 turtles.

The box on the slide shows the sequence of commands that have been executed so far. Commands: fd 5 FD 2 PD PU FD 3 The last two commands I issued lifted up the pen so the turtle does not draw as it moves and then moved the turtles forward 3.

I can save my projects for use in the future. Note that I can then close the project and later reopen it. To clear the code that I wrote in the Turtle Command Center, I can use Edit/Clear. I did a File/Save Project As and seved the project in a directory/folder I created as movedraw.slogo.

I have started a new project here and am moving the turtles and turning them as well. RT means take a right turn RT 90 means turn right 90 degrees. Commands: FD 5 PD RT 90 FD 5 When I executed the sequence of commands shown here, I moved each of the turtles forward by 5, then I put the pen down, then I made the turtles all turn right by 90 degrees and then I made each of the turtles step forward 5 in the direction they were now pointing.

The turtle command center can be used to control the activity of the turtles. When I want to change the number of turtles and things like that, I switch (using the tabs) to the Observer Command Center. In this example, I then clear the number of turtles and then establish that there will only be one turtle. When you start a new project, if you do not want the default of 30 turtles, you must set the CT and CRT. I am doing CT and CRT 1 to get one turtle. Commands: ct crt 1 ct means clear turtles crt means create turtles. must be followed by a number to tell logo how many turtles to create. There are two tabs in the Control Center: one for turtle and one for observer - up until now we have been using the one for turtle. Now I am switching to the one for observer to change the number of turtles.

SETC YELLOW FD 10 PD RT 60 RT 90 FD 20 SETC PINK FD 15 RT 20 FD 5 SETC BLUE LT 90 I pasted the sequence of commands to give a more readable copy. To make the picture I made it is important to execute in exactly the same sequence I did. If a step forward or a turn or a color setting were in a different position, the results would be different. Note the new commands LT for left turn and SETC to set a color. Logo only recognizes the words for standard colors like black, blue, brown, cyan, gray, green, lime, magenta, orange, pink, red, sky, turquoise, white, yellow. These commands are executed in sequence. If I changed the sequence, I would get different results.

PD SETC ORANGE FD 10 RT 90 BK 5 LT 90 SETC LIME FD 5 PU The new command here is BK which means go back. BK 5 means backup 5 steps. Note here that I too the PU, moved forward and then put the pen down. This can also be done with JUMP (see next slide). I pasted a copy of the commands in the white area to show you the commands I used - the actual commands are hard to read.

PD SETC ORANGE FD 10 RT 90 BK 5 LT 90 SETC LIME FD 5 PU JUMP 5 The new command here is JUMP you can see how it works in the example on this slide. Note that again I have pasted a copy of the commands into the white space for readability.

Commands: PD FD 10 RT 90 In this example, I instructed the turtle to create a square. I put the pen down (PD) and then had it go forward 10 and then take a right run of 10 and then go forward 10 and take a right run of 10 until it had created the square. Note that in all of these where there is only one turtle, the observer control contains CT, CRT1 to clear turtles and then create 1 turtle. When you start a new project, you must set the CT and CRT in the observer control center. Note also that the default color is red. When I start a new project, the color will get set to red. Following this sequence, the turtle draws a square. Notice that I am repeating the sequence FD 10, RT 90. In the next slide I will use a loop to make this happen.

Commands: PD REPEAT 4 [FD 10 RT 90] The REPEAT command does whatever is enclosed in the square brackets the number of times indicated. REPEAT 4 means repeat the commands 4 times. The commands are to go forward 10 and then make a right turn of 90. When this is done 4 times, I make a square and end up facing in the same direction as when I started. Commands: PD REPEAT 4 [FD 10 RT 90]

SETC LIME PD REPEAT 3 [FD 10 RT 120] RT 180 SETC PINK In this example I used the repeat to draw the three lines of a triangle and then draw the four lines of a square. See the flowchart on the following page. SETC LIME PD REPEAT 3 [FD 10 RT 120] RT 180 SETC PINK REPEAT 4 [FD 10 RT 90]

Increase # times done by 1 FD 10 RT120 Start Set color to lime Have not done 3 times Y Increase # times done by 1 FD 10 RT120 RT 180 Set color to pink Have not done 4 times Y This shows the logic of the code shown. I set the color to lime and then I do the code in the loop until I have done it 3 times. Then I turn 180 degrees, set the color to pink and do the code in the next loop until I have done it 4 times. Increase # times done by 1 FD 10 RT 90 SETC LIME PD REPEAT 3 [FD 10 RT 120] RT 180 SETC PINK REPEAT 4 [FD 10 RT 90] End

Now I am back to using thirty turtles (the default) Now I am back to using thirty turtles (the default). Be careful of the spacing when you type the commands, logo wants spaces as indicated when I typed the command. The syntax is reasonably strict. The syntax for the if is: if condition [list of commands] The condition is COLOR = PINK I only used one command, FD 10. I could have added other commands which I will do on the next slide. I am using the default of 3 0 turtles and I only want the ones that are PINK to move forward. The code here is checking to see if the color is equal to PINK. If it is those turtles and only those turtles will move forward 10 steps. Note that the FD10 must be enclosed in square brackets because the syntax of logo requires it. COMMAND: IF COLOR = PINK [FD 10]

IF COLOR = YELLOW [PD FD 5] Now I have the results of executing two IF statements. The second one said if the turtle was yellow, I wanted to put the pen down and then move forward 5 which draws a line. Commands: IF COLOR = PINK [FD 10] IF COLOR = YELLOW [PD FD 5]

IF COLOR = YELLOW [PD FD 5] IF COLOR = BLUE [FD 15 PD RT 90 FD 5] Finally, I added the IF command that said if the turtle was BLUE, I wanted to move forward 15, put the pen down, make a right turn of 90 and then move forward 5. This is one of those cases where there is a little flexibility in writing the command. I could have said move forward 15 and then right turn of 90 and then put the pen down before moving forward 5. In other words, it does not matter whether I put the pen down before or after I make the right turn of 90. It does matter that I get the pen down before I go forward 5 or I will not get the effect shown. Commands: IF COLOR = PINK [FD 10] IF COLOR = YELLOW [PD FD 5] IF COLOR = BLUE [FD 15 PD RT 90 FD 5]

IFELSE COLOR = PINK [FD 10] [FD 5] The IFELSE has the following syntax: IFELSE condition [list of commands1] [list of commands2] Which translates as if the conditions is true execute the list of commands1 which is in the first set of brackets. If the condition is not true execute the list of commands 2 which is in the following set of square brackets. See flowchart on next slide. Command: IFELSE COLOR = PINK [FD 10] [FD 5]

IFELSE COLOR = PINK [FD 10] [FD 5] YES NO FD 5 FD 10 If the color is pink step forward 10 else step forward 5. IFELSE COLOR = PINK [FD 10] [FD 5]

IFELSE COLOR = PINK [FD 10] [FD 5] I have a series of IF statements that are executed in sequence and sent turtles forward and back depending on whether they meet the color specified in the condition. IFELSE COLOR = PINK [FD 10] [FD 5] IFELSE COLOR = YELLOW [FD 15] [FD 2] IFELSE COLOR = BLUE [FD 7] [BK 3] IFELSE COLOR = ORANGE [FD 4] [BK 2] IFELSE COLOR = PINK [FD 10] [FD 2] IFELSE COLOR = LIME [FD 5] [FD 1] IFELSE COLOR = PURPLE [FD 3] [BK 1] IFELSE COLOR = MAGENTA [FD 8] [BK 1] IFELSE COLOR = BROWN [FD 5] [FD 2]

IFELSE (COLOR = PINK OR COLOR = LIME) [FD 10] [FD 5] In this example, if the color is either pink or lime the turtle moves forward 10 else the turtle moves forward 5. See the flowchart on the next slide. IFELSE (COLOR = PINK OR COLOR = LIME) [FD 10] [FD 5]

COLOR = PINK YES NO FD 10 COLOR = LIME YES FD 5 FD 10 If the color is either pink or lime you want to move forward by 10 steps else you want to move forward by 5 steps. IFELSE (COLOR = PINK OR COLOR = LIME) [FD 10] [FD 5]

IFELSE (COLOR = PINK OR COLOR = ORANGE OR COLOR = LIME) [FD 10] [HT] HT means hide turtle and ST means show turtle SHOWN? tests to see if the turtle is shown or visible. Note that I put parenthesis around the whole condition on the first IFELSE and did not put parenthesis around the whole condition on the second IFELSE. They both worked proving that the parentheses are optional. IFELSE (COLOR = PINK OR COLOR = ORANGE OR COLOR = LIME) [FD 10] [HT] IFELSE COLOR = ORANGE AND SHOWN? [FD 10] [FD 5]