Using Logo and Logic Please use speaker notes for additional information!

25
Using Logo and Logic Please use speaker notes for additional information!

Transcript of Using Logo and Logic Please use speaker notes for additional information!

Page 1: Using Logo and Logic Please use speaker notes for additional information!

Using Logo and Logic

Please use speaker notes for additional information!

Page 2: Using Logo and Logic Please use speaker notes for additional information!

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).

Page 3: Using Logo and Logic Please use speaker notes for additional information!

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.

Page 4: Using Logo and Logic Please use speaker notes for additional information!

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

Page 5: Using Logo and Logic Please use speaker notes for additional information!

Commands (SEQUENCE):fd 5FD 2PDFD 2

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.

Page 6: Using Logo and Logic Please use speaker notes for additional information!

Commands: fd 5 FD 2 PD FD 2 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.

Page 7: Using Logo and Logic Please use speaker notes for additional information!

I did a File/Save Project As and seved the project in a directory/folder I created as movedraw.slogo.

Page 8: Using Logo and Logic Please use speaker notes for additional information!

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.

Page 9: Using Logo and Logic Please use speaker notes for additional information!

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.

Commands: ct crt 1

ct means clear turtlescrt means create turtles. must be followed by a number to tell logo how many turtles to create.

Page 10: Using Logo and Logic Please use speaker notes for additional information!

SETC YELLOWFD 10PDRT 60FD 10RT 90FD 20SETC PINKRT 90FD 15RT 20FD 5RT 10FD 5SETC BLUEFD 10RT 90FD 10RT 90FD 10LT 90FD 20

These commands are executed in sequence. If I changed the sequence, I would get different results.

Page 11: Using Logo and Logic Please use speaker notes for additional information!

PDSETC ORANGEFD 10RT 90BK 5LT 90SETC LIMEFD 5LT 90FD 10LT 90PUFD 5PD FD 5

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.

Page 12: Using Logo and Logic Please use speaker notes for additional information!

PDSETC ORANGEFD 10RT 90BK 5LT 90SETC LIMEFD 5LT 90FD 10LT 90PUFD 5PD FD 5JUMP 5FD 10

Page 13: Using Logo and Logic Please use speaker notes for additional information!

Commands: PD FD 10 RT 90 FD 10 RT 90 FD 10 RT 90 FD 10 RT 90

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.

Page 14: Using Logo and Logic Please use speaker notes for additional information!

Commands: PD REPEAT 4 [FD 10 RT 90]

Page 15: Using Logo and Logic Please use speaker notes for additional information!

SETC LIMEPDREPEAT 3 [FD 10 RT 120]RT 180SETC PINKREPEAT 4 [FD 10 RT 90]

Page 16: Using Logo and Logic Please use speaker notes for additional information!

SETC LIMEPDREPEAT 3 [FD 10 RT 120]RT 180SETC PINKREPEAT 4 [FD 10 RT 90]

Start

Set color to lime

Have not done 3 times FD 10 RT120

Y Increase # times done by 1

RT 180

Set color to pink

Have not done 4 times FD 10 RT 90

Y Increase # times done by 1

End

Page 17: Using Logo and Logic Please use speaker notes for additional information!

COMMAND:

IF COLOR = PINK [FD 10]

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.

Page 18: Using Logo and Logic Please use speaker notes for additional information!

Commands:

IF COLOR = PINK [FD 10]

IF COLOR = YELLOW [PD FD 5]

Page 19: Using Logo and Logic Please use speaker notes for additional information!

Commands: IF COLOR = PINK [FD 10] IF COLOR = YELLOW [PD FD 5] IF COLOR = BLUE [FD 15 PD RT 90 FD 5]

Page 20: Using Logo and Logic Please use speaker notes for additional information!

Command:

IFELSE COLOR = PINK [FD 10] [FD 5]

Page 21: Using Logo and Logic Please use speaker notes for additional information!

COLOR = PINK

FD 10FD 5

IFELSE COLOR = PINK [FD 10] [FD 5]

YESNO

Page 22: Using Logo and Logic Please use speaker notes for additional information!

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]

Page 23: Using Logo and Logic Please use speaker notes for additional information!

IFELSE (COLOR = PINK OR COLOR = LIME) [FD 10] [FD 5]

Page 24: Using Logo and Logic Please use speaker notes for additional information!

COLOR = PINK

FD 10

FD 5

COLOR = LIMEYES

YESNO

FD 10

IFELSE (COLOR = PINK OR COLOR = LIME) [FD 10] [FD 5]

Page 25: Using Logo and Logic Please use speaker notes for additional information!

IFELSE (COLOR = PINK OR COLOR = ORANGE OR COLOR = LIME) [FD 10] [HT]IFELSE COLOR = ORANGE AND SHOWN? [FD 10] [FD 5]