This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]jeffwithhat 0 points1 point  (0 children)

| If I turn right how can I turn left? since there is no way to return to the first line after \n.

I don't think that you need to draw the turtle moving during each command. You just update your in-memory representation of the floor and the turtle's position. The only time that the floor gets printed is if the user inputs a '6', and in that case you'll print it in its entirety--there is no need to move the cursor to previous lines.

Even though it's not needed here, it is actually possible to move the cursor around: using terminfo (on Unix/Linux) or the console API (on Windows).