Hessischer Bildungsserver / Arbeitsplattformen

The Turtle for SWI-Prolog

The programming language LOGO was designed for educational use in programming. It has as special graphic conception the Turtle. The idea is that a Turtle with a pen strapped to it can be instructed to do simple things like move forward 100 spaces or turn around.

The turtle graphics is simpler to handle than coordinate geometry. The direct visual feedback of turtle programming is motivating and facilitates the introduction to programming.

The Turtle for SWI-Prolog, provided here, knows the following methods:

turtle_init Provides a Turtle with a 400x300 pixel large window. The Turtle is positioned into the center of this window and looks to the right.
turtle_draw(L) The Turtle draws a line of length L in the current direction.
turtle_drawto(X, Y) The Turtle draws a line from the current position to the point P(X/Y).
turtle_turn(W) Turns the drawing direction relatively by angle W.
turtle_turnto(W) Sets the drawing direction absolutely to angle W.
turtle_move(L) Moves the Turtle in the current direction a line of length L without drawing.
turtle_moveto(X, Y) Sets the turtle to the point P(x/y)

With the following commands an equilateral triangle can be produced:

turtle_init.
turtle_draw(100).
turtle_turn(120).
turtle_draw(100).
turtle_turn(120).
turtle_draw(100).
turtle_turn(120).

As result one receives:

How to use

Download the Turtle and save the file in the library-directory of your SWI-Prolog-System. The filedate has to be up-to-date. Then make the query ?- make. in SWI-Prolog, so that afterwards the turtle can be used like a system-modul.

Examine finally with the program above whether the Turtle is successfully installed.