We are pleased to announce that turtleSpaces now supports offline use of the web-based Integrated Development Environment. Simply download turtleSpaces for your relevant platform, and once you’ve signed in to a local account, type IDE in the console.
Your default web-browser should then open with the IDE in a new window or tab. You can use this IDE to control your local copy of turtleSpaces. This means that execution of Logo programs will generally happen much faster. Loading and saving will happen to / from your local turtleSpaces folder (present in your home or User folder).
turtleSpaces is great for creating 3D models and animations, but we also want it to be great for games. Unfortunately, the interpreter is not the fastest thing around — but that’s okay! We can compensate by creating new commands that work ‘under the hood’ to take care of certain game elements.
Bales are groups of turtles that all execute the same code, for example alien attackers in a space battle game. They are declared similarly to turtles, using a NEWBALE declaration.
When each member of a bale is initialized, it executes the code in the bale’s INIT procedure. Then, it repeatedly executes the code in the MAIN procedure in sequence with the other members of the bale, that is each member of the bale executes the code in succession using the same thread. At the end of each cycle, when all bale members have executed, their ‘turtle tracks’ are rendered. This makes it seem like they’ve all moved at the same time.
NEWBALE "ships
TO init
;bales are groups of turtles that execute the same code in sequence,
;one after the other. They are useful for things like groups of
;enemies, to keep them in lock step, where hatchlings can end up
;executing at different rates of speed and fall out of sequence
;with each other.
;new bale members always execute the init procedure, after which
;they repeatedly execute the main procedure until they are
;removed or the entire bale is stopped.
penup
noaudiowait
newmodel "bullet [setfillcolor 15 icosphere 1.5]
setmodelscale 1.5
setposition {
(-150 + 30 * (remainder baleindex - 1 5))
100 - (20 * (int ((baleindex - 1) / 5)))
5
}
;based on the number (index) of the bale member, place
;it in the attacking wave
if 1 = remainder int (baleindex - 1) / 5 2 [setx xpos + 10]
;let's offset the turtles in alternating rows
right 180
;turn to face down
showturtle
;show the turtle
rollright baleindex * 10
;set the default roll rotation
output [dir 1]
;the pairs provided by output become variables in main
;in this case we're setting the default move direction, which
;is the same for all members in this bale
END
Each member of the bale is placed based upon its index number in the bale. Once we position the bale member, it moves on to the main execution loop:
TO main
dosleep 10 [
;take at least 10 milliseconds to do the following:
rollright 10
;roll right ten degrees
if and xpos < 150 :dir = 1 [drift 5 [1 0 0] drift 1 [0 -1 0]] if and xpos = 150 :dir = 1 [make "dir 0 drift 10 [0 0 -1] drift 10 [0 -1 0]] if and xpos > -150 :dir = 0 [drift 5 [-1 0 0] drift 1 [0 -1 0]]
if and xpos = -150 :dir = 0 [make "dir 1 drift 10 [0 0 1] drift 10 [0 -1 0]]
;we use drift to move the ships because we're rolling them for effect
if 1 = random 20 [
newmissile "missile "bullet [0 -1 0] 20 + random 20 [200]
playsound "zap3
]
;fire a missile randomly
if or ypos < -100 containsp "myrtle near position 20 [ make "hit true ] ;if an alien reaches the bottom of the screen it's over if baleindex = last balemembers balename [ if :delay > 0 [dec "delay]
;this increases the speed of the invaders 'music'
;once each time all the bale turtles have executed
;(each loop)
]
]
END
Each bale member moves across the screen, randomly firing missiles, until they are destroyed or reach the bottom of the screen, triggering a ‘game over’ condition.
Missiles are simple elements that are controlled by the game engine. They move through 3D space, and are detected by primitives such as NEARMISSILEP and NEARMISSILES. They can also be detected by the nearmissile trigger. They are much more efficient than using turtles as projectiles.
Similarly, triggers are blocks of code that are executed when a certain condition occurs. These conditions are monitored by the underlying game engine, and are ‘triggered’ when these conditions are detected to be true. Once again, this is much more efficient then having a turtle constantly execute Logo code waiting for the condition to occur!
The following trigger belongs to the previously mentioned alien ships bale:
ON boom nearmissile block [missile2 10]
hideturtle
playsound "explosion
inc "score
show :score
stopmissile flat list :boom :boomanim
die
;this turtle is no more
END
This trigger increments the player’s score, disposes of the missile that triggered it, and then ends the turtle to whom the trigger belongs, in this case a member of the alien ship bale.
As you can see, bales, missiles and triggers all contribute to empowering turtleSpaces coders to create faster-paced, more engaging games.
Environments are a cool new way to get started with Logo. turtleSpaces now provides a variety of environments in different settings to inspire Logo creation:
Starry Night and Star Platform – Myrtle builds in space!
Winter Ice Pond – Myrtle goes skating!
Pyramid Desert – Build a monument to the Gods!
Under the Sea – Shelly swims with the fishes!
Forest Cabin – Myrtle’s hideaway in the woods.
City Park – Myrtle plays in Central Park!
Parking Lot – Myrtle learns to drive.
The Moon Base – Myrtle on the Moon!
Alien Trees – A ring of growing alien trees.
Environments are available in both the desktop application and the web application. In the web application, you can find them when you start a new project (under the file menu). On the desktop, you open them the way you open examples, in the environments folder.
Environments are written in Logo and are randomly created when they are opened, so some of them may take a minute or two to fully form. You can’t see the environment code in the built-in editors as they are managed by system turtles, which can be used to program the broader Logo environment for purposes such as environments, tutorials and games that use the Logo interpreter to interact with them.
But if you download the procedures, or look at them in an external text editor, you can see the code that makes up the environments, and tweak them, or use them as a template to create your own!
To make turtleSpaces more accessible to our users, we’ve created a WebAssembly build of turtleSpaces and paired it with a new Javascript front-end UI that renders turtleSpaces output natively in the browser, and has a code editor with syntax highlighting.
It comes with a number of built-in examples, and a fairly complete set of features: loading from the local machine, saving to the local machine, exporting STL, exporting PNG (high-resolution), and sharing using the turtleSpaces model viewer (which unlike STL is in full color).
Obviously execution in the web interface is slower than if you download the native turtleSpaces binary for your operating system, but our webLogo still provides most of the functionality of turtleSpaces while making it available for other platforms such as Chromebooks, Raspberry Pi 4 and so forth (anything that can run a Chromium-based browser).
And, because it is 3D, and has dozens of shape primitives, our webLogo still offers far more creative opportunities than other Logos.
On our journey to porting turtleSpaces to the Web (yes, that’s coming!), we’ve added a primitive, SHAREVECTORS “description (or |description|) that allows users to share their creations to the web. SHAREVECTORS will return a link to the turtleSpaces website where you can view a static model, as it was in turtleSpaces when you executed the SHAREVECTORS command.
Note that the camera in the web viewer is currently fixed to the Y axis and is oriented upward, and so you need to ensure your models are oriented that way (they should look correct if you issue a CAM:CS to return the camera turtle to its home position).
You can also embed the viewer (and your creation) into your own web page if you use the following bit of code:
replacing YourSceneHere with the ID of your scene (the bit in the share URL after pict= and before the ” that follows it) which looks something like 8970c41a0c9a35553e6a2613f8b0516c67381e9a556beb647de84c09
Note: Due to limitations with WebGL, pen width is not currently supported.
You can click and drag to rotate the model, or use the scroll wheel to zoom in and out.
These allow you to “skew” (or slant) the created shape and / or compress or expand one “end” of it (trape, or trapezoidal). This allows for a large increase in the number of possible shapes you can create in turtleSpaces.
Also, you can export an arbitrarily-sized render of the current scene using the new SAVEPNG primitive:
SAVEPNG [width height] “filename.png
Note that if you specify a really large size (> 10000 pixels per side) you can cause the application and even your operating system to crash! This is because the rasterisation needs to be done in memory.
The image is saved in the current “working directory”, usually a turtleSpace TSP folder inside of your user folder (inside of the turtleSpaces folder in your home directory).
We’ve also created a lot of short-hand primitives for shapes. You can find them listed in the shapes and graphics reference.
Don’t want to download the turtleSpaces client just yet? Well, you can take turtleSpaces for a bit of a spin using Myrtlebot, our turtleSpaces Twitter Bot! Myrtlebot executes whatever Logo code (not procedures yet) you tweet at her, and then returns an image of the results. In the future, we plan to allow for the recording of movies, but for now it’s just a still image. If your code runs for more than 60 seconds, it will be cut off at the 60 second mark.
Hey @botwikidotorg Hi! I’m a bot who renders 3D #Logo programming code (https://t.co/eEMtYeyt0Y) and returns a picture of it. In the future I plan to return short video clips. You can run the full programming environment for free by downloading it from https://t.co/Io78IMEOUh
— MyrtleBot: a turtleSpaces Logo Bot (@myrtlebot) January 31, 2021
We’ve created a number of ‘short codes’ for various graphics primitives so that you can put more into a tweet. Here are the new ‘short codes’ (along with the typical logo rt, lt, fd, bk, up, dn etc.) See the documentation for a fuller description of each primitive:
turtleSpaces has a new primitive, SAVESTL, which can be used to export 3D models of the current turtleSpace.
savestl "modelname
creates a new folder in the current project folder (TSP) with the extension MDL (eg modelname.mdl), inside which contains STL format files, one for each color used in the space. These files can be used with other 3D applications (such as the pictured viewstl.com website), and can be 3D printed (although the sides of objects may need to be extruded using another application first, if the desire is for the objects to be hollow).
Another primitive, SETSTLLINETHICKNESS, is used to set the radius of the ropes used to represent lines in exported STL files. It takes a number.
You can communicate with turtleSpaces over a socket (telnet) connection to port 1967.
First you need to issue the API command inside of turtleSpaces to enable API connections, or use the -enable-api flag when starting up.
Then connect to turtleSpaces from an external application or terminal. You can issue instructions to affect turtles and the environment just like you would do inside the turtleSpaces application.
The API connection executes as its own worker. You can also redirect input and output to the API instance by using setread “api and setwrite “api – but these must be issued by the API worker itself to redirect to that worker (if you use another API connection, reading and writing will be redirected to that API instance, for example).
Using the API, you can use turtleSpaces as a visualiser for another application, and have it act as a light organ, or create charts and graphs.
turtleSpaces implements the Logo programming language inside of the OpenGL 3D graphics environment, allowing you to use turtles to construct 3D models and create animations, simulations and games.
We initially implemented a version of Apple Logo II in our microM8 Apple II emulator to make it easier to use for our younger users, and because microM8 itself uses OpenGL to render the Apple II’s graphics (also in 3D) we added some rudimentary 3D commands to it (up, down, rollleft, rollright, etc.)
We received positive feedback from our users and decided to seperate the Logo interpreter from microM8 and work to grow its potential more broadly.
Why Logo?
Logo’s benefits for learning how to code are many and varied, but before we explore them, it might be better to address the concerns many have with it first, and get them out of the way.
Why not Logo?
Logo’s problems are mainly historical. In the late 1970s there was great excitement among some quarters regarding the potential benefits of teaching children computer programming. Logo was designed around this time to be an as easily-accessible programming language as could be achieved given the technology of the era, which was not very advanced and led to extreme tradeoffs between usability and practicality. In short, Logo was still difficult to use, while not being useful for very much.
Despite this, evangelists (including and mainly Logo’s co-architect Seymour Papert) still made a big deal of Logo, and attempted (and for a time largely succeeded) to gain its widespread use in education, engaging in a great deal of publicity and the making of overstated promises about its potential to turn every child who used it into a little genius. To make matters worse, Papert’s constructivist philosophy dictated that children be allowed to ‘explore’ Logo at their own whim, which while valid on its face (and is something we encourage with turtleSpaces!) was impractical in the context of the crude interpreters that were made available at the time, which were slow, unforgiving, low-resolution and had limited built-in tools, resources and examples.
To make any use of it, you really had to read the manual, but since reading the manual ran counter to Papert’s philosophy, many kids just figured out how to move the turtle forward and turn, and that was about it. Studies were done that showed some initial tutorial-based hand-holding was required, and improvements needed to be made in the user interface, and while later versions of Logo did attempt to correct these shortcomings, by that time the initial enthusiasm for Logo amongst educators had died out, and they were somewhat jaded to the concept in general.
Logo appeared too early, and pushed too hard.
In response, ‘blocks’-based versions of Logo appeared such as Scratch, which attempted to make a subset of commands and their parameter requirements obvious to young coders, who could ‘snap’ them together in the correct order and change default parameters and witness their effects. While useful perhaps in the near-term (and to be clear, we are in the process of implementing a blocks-style mode in turtleSpaces, so we agree they are not without value as an early introduction to Logo), these reduced the very valuable concept of the Turtle to little more than a gimmick, and they nobbled the potential of the Logo language they were based on so much as to make greater exploration of the language largely impossible in the context of their environments.
They were, and are, ‘dead ends‘, and this causes some concern to parents and educators, many of whom are reluctant to use them.
That isn’t to say there weren’t and aren’t other full-Logo interpreters also out there. There were and are, but they have also faced difficulty. First, they’ve tended to rely heavily on the host operating system’s user interface, which was a popular direction to go in the late 1990s and early 2000s, but not so much recently. MicroWorlds Logo, for example, allowed the user to create buttons and load images, and so forth. But the programs users created were very much restricted to their environments, and those environments were still very much oriented towards children. And this trend continued, making for very limited experiences.
As a result, given today’s cross-platform, limited UI landscape these have not aged well. Other developers implemented variants of Logo (such as NetLogo) designed for simulations, such as ant colonies or viruses. But these are largely targeted toward college students, and many of their mechanisms are in our opinion convoluted and counter-intuitive and not at all suitable for children.
Logo for children was simply a victim of being in the wrong place at the wrong time, and its stunted evolution reflected that. But there’s nothing wrong and a lot very right with Logo, and studies of the language itself have shown that. Its functional nature is fairly easy to grasp, the immediate feedback you get from the turtle promotes exploration and learning, and it is powerful enough to become a go-to language for someone even as an adult, if there was a Logo environment that was flexible enough to be useful for a broader audience, and could occupy that middle ground.
So we thought, “Why couldn’t we find that middle ground? We have the technology! Why don’t we go back to where it all started and work forward from there?”
I’d like to definitively state that we have succeeded in our task, but I’ll more tentatively say that we’re well into working on it. Here’s what we have accomplished so far:
The addition of a few hundred useful primitives from other Logos and programming languages (including some of our own invention), such as multiple turtles and threading, loops and math functions, retro-styled music and sound, turtle models, gamepad and image placement primitives
Several hundred primitives related to the 3D environment, including a wide variety of shapes, positional and vector based functions and tools, and Minecraft-inspired pixelated color schemes
An improved while retro-inspired interface that is able to easily get out of the way – no tiny window into the Logo world, no large obtrusive text areas that you can’t get rid of. You can make a program and execute it full screen just like any other game you might buy or download.
Written in Go so it’s cross-platform (Windows, macOS and Linux) with the potential for mobile platforms
Lots and lots of other smaller things that make the whole experience fun, engaging, productive and straightforward that I can’t even begin to mention.
Here’s a list of some big-ticket items that still need to happen (in no particular order):
Raspberry Pi, iOS and Android support, in particular for running turtleSpace apps
Stand-alone, distributable app generation for mobile and desktop
Private “Classes” that groups of students can join, whose progress can be viewed and monitored by their facilitators / teachers, who can share content between their students
Multi-user, multi-player capabilities so that users can design, code and play together
API to support control by other applications such as IDEs and tutorials
The ability to connect and interact with the outside world
3D model import / export so that users can 3D print their creations, or use them in other 3D environments or vice-versa
Terrain and more complex shape design tools
In-environment tutorials, badges, achievements and so forth to encourage exploration
‘Blocks’-based entry mode to support younger learners
Command-line version without the OpenGL baggage, but with internal FauxGL rendering support to enable image output
Refactoring and optimization!
A whole bunch more primitives!
Finally, and most importantly, to make Logo the relevant all-purpose language it was always meant to be
So, a long way to go. But a good start. Hope to see you around turtleSpaces soon!