views:

14031

answers:

37

How do I move the turtle in LOGO?

+47  A: 

Logo is all about moving the turtle... you give it commands like this:

Forward 100
Right 45

You can do stuff like repeating commands too:

Repeat 8 [Forward 100 Right 45]  ; Draw an octagon

(What do I win? 8-)

RichieHindle
Careful not to tear the paper
skaffman
Gah! Are you using a single ')' as both part of the emoticon AND to close the parenthetical statement? -1 for you!
Pesto
@Pesto: Of course! Those parentheses don't grow on trees you know!
RichieHindle
STEWIE: Your sentence is what Brian? Over.BRIAN: My sentence is… wait I have to say over even if the sentence ends with the word over?
Ian Patrick Hughes
@Richie Have you never Lisp'd? parentheses grow EVERYWHERE.
they grow on the lisp trees in the deeply nested parenthetical forest.
Carson Myers
they gwow on twees, shirley
skaffman
@Rich: I wear glasses, but I don't have a beard.
RichieHindle
@Pesto xkcd.com/541/
Skilldrick
Parenthesis grow everywhere, but then again you have to fight lispers for them... and lispers are ferocious when everything turns around parenthesis, you know, there is not much else the world could turn around.
David Rodríguez - dribeas
@Richie: turtle can also change colors. like rainbow.
rwong
+13  A: 

It runs when you say Boo!

zvolkov
Aw c'mon. A down vote? There's no room for comedy among this cut throat crowd.
Ian Patrick Hughes
+9  A: 

Whoa! Is it still around?

fd 300 // Forward
rt 90  // Right 90°
fd 300 
lt 90  // Left 90°

That used to work.

xenon
+178  A: 
//MOVE FORWARD
FD 75
//TURN RIGHT
RT 54
//TURN LEFT
LT 21
//MOVE BACKWARD
BK 17

Check out some other turtle commands found here...


Turtle Commands

BACK ## [BK] - Move turtle back

BACKGROUND ## [BG] - Set Background color (0-15)

  • 0 - Black
  • 1 - White
  • 2 - Red
  • 3 - Cyan
  • 4 - Purple
  • 5 - Green
  • 6 - Blue
  • 7 - Yellow
  • 8 - Orange
  • 9 - Brown
  • 10 - Light Red
  • 11 - Grey 1
  • 12 - Grey 2
  • 13 - Light Green
  • 14 - Light Blue
  • 15 - Grey 3

CLEARSCREEN [CS] - Clear Screen without moving turtle

DRAW - Clear Screen and take turtle home

EACH - Tell several sprites, whose numbers are in a list, to accept commands in a second list. EG. EACH [1 2] [SQUARE 10]

FORWARD ## [FD] - Move turtle forward

FULLSCREEN - Full graphics screen (same as pressing F5)

HEADING - Output turtle heading as a number (0-359)

HIDETURTLE [HT] - Make turtle invisible

HOME - Move turtle to center of screen pointing up

LEFT [LT] - Turn turtle left

NODRAW [ND] - Enter text mode with clear screen

NOWRAP - Prevent drawings from wrapping around screen

PENCOLOR [PC] - Change pen color

PENDOWN [PD] - Turtle leaves trail

PENUP [PU] - Turtle ceases to leave trail

RIGHT ## [RT] - Turn turtle right

SETHEADING **[SETH]** - Set turtle heading eg. SETH 180

SETSHAPE - Set the current sprite shape (0-7)

SETX Move the turtle to the specified x co-ordinates Eg. SETX 50

SETXY Move the turtle to the specified x, y co-ordinates Eg. SETXY 50 50

SETY Move the turtle to the specified y co-ordinate Eg. SETY 50

SHAPE - Output number of current sprite's shape

SHOWTURTLE [ST] - Make turtle visible

SPLITSCREEN - Mixed graphics and text screen (same as pressing F3)

STAMPCHAR - Make the turtle stamp a character at the current location Eg. STAMPCHAR "A

TELL - Tell designated sprite to receive commands. EG. TELL 2

TEXTSCREEN - Use whole screen for text (same as pressing F1)

TOWARDS - Output heading for turtle to face an X,Y co-ordinate. Eg. TOWARDS 0 0

WRAP - Make turtle drawings wrap around the screen

XCOR - Output current x co-ordinate of turtle

YCOR - Output current y co-ordinate of turtle

ASPECT - Set verticle screen scale factor, default is 0.76


Samples taken directly from website: http://gaza.freehosting.net/logo/index.html

RSolberg
MY EYES .
George Stocker
Mine too... And I copy and pasted it :)
RSolberg
Nicely edited, Gortok.
Ian Patrick Hughes
Wow, this brings back old memories (my first programming language!)... :-)
Zifre
SETXY Make the turtle do an alluring dance
Daniel Earwicker
+1 for skilled point farming
SomeMiscGuy
@Zifre: my second (Apple BASIC was first...) but yep, **old** memories from the dawn of time... :)
GalacticCowboy
@Christopher - you're giving me way more credit than I deserve for that... I had no idea it'd blow up like this... Just answering questions...
RSolberg
+4  A: 

try: bk(back), fd(forward), ld(left turn in degrees), rt(right turn)

neesh
+25  A: 

Don't forget PENUP and PENDOWN. Otherwise you'll move the turtle, but not see his track. Also change the color of the pen, and the background color of the paper.

abelenky
...and PENERASE!
Chetan Sastry
+230  A: 

The first thing you have to do is write tests, then you can worry about moving the turtle.

Greg
I don't think TurtleUnit is still being maintained, sadly.
skaffman
If I had to maintain turtles' units all day, I think I'd kill myself. "How did you guys make it this far as a species if your units keep breaking?!"
Pesto
TurtleUnit doesn't really need too much maintenance. Mock Turtles make testing almost any imaginable Spirograph a breeze.
TokenMacGuy
LOL... Awesome comment! :-)
Pablo Santa Cruz
Hilarious, xanadont! Upvoted :D
Huxi
+8  A: 

You go here... http://www.sonic.net/~nbs/webturtle/webturtle.cgi

Sam
@Sam: Dammit, I was going to do some work today!
RichieHindle
@Sam: I love Sonic.Net by the way. Great ISP.
Ian Patrick Hughes
As far as I can tell, that's not actually LOGO...
Jon Bright
That's great! Ahhh...bringing back the memories of Camp Comp-u-Surf where I won the Logo programming competition on an Apple ][+ back in ~1984
Stu Thompson
+10  A: 

This seems somewhat philosophical - is the turtle an inherent part of the language, or part of its library? Ie., is the turtle more part of a LOGO library that exists only in interpreter-land, or is the turtle part of the LOGO language itself?

If we're speaking in terms of the language definition, I guess no, there really isn't a way to move the turtle. If we're speaking about an actual interpreted LOGO program, any of the answers where others describe turtle commands are valid.

I'm a pragmatist though, and thus like the idea of speaking of a concrete LOGO entity. That, of course, allows you to move the turtle using turtle commands.

sheepsimulator
+5  A: 

Try the story about the dying kid and the firefighters. You might need to adapt it slightly.

Colin Pickard
Probably downvoted by people who dont realize that story is sued to teach Logo... Logo being a programming language for kids and all.
Neil N
^"used", not "sued"
Neil N
+77  A: 

i like turtles

Ryan
...all riiight, you're a great zombie!
ctd
Why does this have 33 upvotes? This type of answer should be buried! (+1)
Isaac Waller
ROFL ... I love your answer! So appropriate...
Ray Burns
http://knowyourmeme.com/memes/i-like-turtles
Kevin Panko
I like turtles.
DMin
+3  A: 

Zombie kid loves turtles, too :)

Pure.Krome
+6  A: 

I've seen a few LOGO implementations where you can use localized commands like:

  • NAPRZOD (FORWARD),
  • LEWO (LEFT),
  • PRAWO (RIGTH)

or even NAPRZÓD (with Polish letter Ó).

LOGO is nice language to teach kids programming in their native spoken language.

Grzegorz Gierlik
+5  A: 

“Ne craignez point, monsieur, la tortue” Leibniz ( do not fear the turtle )

Pete Kirkham
+1 For J. L. Borges quot
Alejandro
+6  A: 

Have you tried JavaScript?

Dinah
+1. What if you use SQL Server? https://stackoverflow.fogbugz.com/default.asp?W29041
eed3si9n
+21  A: 

A croquet mallet ?

Martin Beckett
+67  A: 

First, you have to understand that there is a lot of legacy turtle-moving code at Fog Creek in VBScript. This code contains years of bugfixes and special cases for turtle-moving. If you re-write it from scratch you are asking for disaster. Plus, it would set back the next release by months. Customers want new features, such as new turtle shapes and 3D motion, and they literally don't care what the code looks like. They just want to move their turtle.

It's actually easier to write your own compiler to translate your legacy code into Logo. This allows you to add other features to the language that VBScript didn't originally support, like Excel macros. It's not that hard, as long as you hire someone smart.

Steve Hanov
And if you have enough bugs you can even write your own bug tracker - eventually when the bug tracker is larger than the original project you can sell the bug tracker
Martin Beckett
We'll call it FogTURTLEZ.
Kyralessa
+1 for Awesomeness
DrFloyd5
substitute business for turtles.
rwong
+4  A: 

If you've got one of the actual robotic ones (we did at school) then a good "foot up the behind" gets it moving pretty well.

ck
A: 

You cannot move the turtle. The turtle must move itself.

Sharkey
the turtle can't move itself without you.
Erika
Show it a strawberry to motivate the turtle to move. Mine likes strawberries a lot.
Tadeusz A. Kadłubowski
+36  A: 

Boy: Do not try to move the turtle; that's impossible. Instead, only try to realize the truth.
Joel: What truth?
Boy: There is no turtle.
Joel: There is no turtle?
Boy: Then you will see, it is not the turtle that moves, it is only yourself.

Damn you! Beat me to it. :-)
Daniel
that is such bullshit. it is not only yourself that moves.
Erika
that is solid gold, im sitting here giggling, this comment should be up the top of the list
Aran Mulholland
substitute turtle for: (i) stock price. (ii) SO reputation.
rwong
+4  A: 

There is an art to moving the turtle, or rather a knack. The idea is to throw the paper at the turtle ...

boost
Always a +1 for gratuitous Douglas Adams references...
Electrons_Ahoy
Thanks. Glad someone spotted and rewarded accordingly.
boost
A: 

Create your own logo language is a good exercise to learn writting a lexer and a parser by the way.

Aif
+1  A: 

SmallBasic has a Turtle too.

Adrian
+1  A: 

Of course, when using Logo to tell turtles to do things you might want to use the shell and you would use TortoiseSVN for the source repository.

Tim
Wah wah waaaah.
MatrixFrog
http://sadtrombone.com
Jeff Atwood
This is funny and I'm tempted to send my +1 into the vote wars ... but Tim has forty times my reputation so I'll let it go.
Smandoli
I +1 one of your questions
Tim
+15  A: 

How do you move the turtle in LO

GO? That's not a language we know.

Can turtle still move, if language is dead?

Can language still move, if syntax is shed?

Or maybe a new kind of language instead!

Okay if the movement is just in my head?

How do you move the turtle in LO

GO? ... you could try STACKOVERFLOW.

Smandoli
triple upvote, ka-ching bam wooly wooly. (but how???)
Erika
+3  A: 

This brings back lots of memories... so many school breaks spent alone in the room with the computers, programming without knowing what the heck i was exactly doing.

Good times.

Justanotheraspiringdev
I like this, but I like the number zero so I'm not upping it.
Erika
+3  A: 

By issuing commands in the correct syntax. E.G.:

forward 100

There is only one necessary command to move the turtle. It is forward which has the mnemonic fd. When working with a robot (real) turtle as opposed to a graphics based (virtual) one, you might find that the turning commands left and right [lt & rt] move the turtle a little, accidentally.

Most implementations also allow the command backwards [bk].

When the turtle moves, it may draw a line as it goes depending on whether the pen is up or down at the time, and whether the current pen color is different from the background color.

A graphics based (virtual) turtle can also jump around the screen with setx, sety, and setxy

dlamblin
+4  A: 

First, you will need to somehow load the core Win32 APIs from User32.dll as external functions so you can create a graphics context from the window where you want the turtle to be. I myself do not know how to do this with LOGO, but I know there are some other experts which are willing to help you out here. Note that LOGO is an old language, so if you are working in a 16 bit environment, you will likely need to properly thunk the appropriate DLLs. Next, you will need to load the turtle bitmap from your resource file, or alternatively, from your executable should your resources be direct-compiled into your build artifacts.

Now be careful about your resources here. If you don't properly dispose of your graphics contexts, bitmaps, and pens, your Windows machine could run out of handles. Next, you'll want to intercept the WM_PAINT message and then check against your main timer routine to make sure that it's time for the turtle to move. Take care not to call a turtle moving procedure from a worker thread, or you could experience stability problems, especially if you try to marshal your resources across thread boundaries.

Now then, it is important to understand that you will need to repaint any areas of the turtle, once moved, if and when your window's area is invalidated. In order to do this efficiently, you will need to use the parameters supplied with the WM_PAINT message to properly establish your clipping rectangle so that performance does not suffer if only a small region of your window is invalidated.

Dave Markle
+10  A: 

Ask not what the turtle can do for you, but what you can do for the turtle.

boost
+3  A: 

I'd start by first working my way through K&R C to improve your programming skills! ;-)

Rob Wells
+3  A: 

Use the force, Joel. Use the force.

A: 

There is no turtle. It is you that moves.

Kevin Laity
+5  A: 

Move the monitor

PeteT
+4  A: 

Moving the turtle is very cumbersome. I recommend that you try TurtleQuery. It makes everything way easier by abstracting away the turtle.

Earlz
+1 TurtleQuery is more popularly known as tQuery, and the syntax is just so much better than the original. `$().fd("20");`
Anurag
@Anu LOL! ` ` ` `
Earlz
A: 

Ask the turtle itself or press F1.

this. __curious_geek
A: 

"LOGO considered harmful" did not return any result on Google. I consider this to be a very good sign.

rwong
+4  A: 

You should totally drop that and try jQuery.

George Edison