links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Construct a maze with Etoys
Last updated at 11:37 am UTC on 6 May 2019
In the project catalog of the Squeakland web site you find a maze constructor project file.

On this page you will learn how Etoys was used build to build a maze.
This will allow you to generate various kinds of mazes.

This page is work in progress. The instructions will be written for the Squeak 5.2 release.


How I Made a Maze Constructor

Before starting:

I started out with thinking about a simple algorithm for constructing mazes:

I have a rectangular area (playfield) with a dot on it which may move like a turtle.

1. Move forward a random direction.
2. Check: Is area under empty ?
3. Yes: Draw a line to here and start over with step 1.
4. No: Move back and start over with step 1.

I opened the 'objects' flap and brought out a playfield as the world for my maze.
I adjusted the size of the greenish playfield to have the size I want it to have,

Then I choose an ellipse for the turtle and set the dimensions in a way that it appears as a circle.

I opened a viewer on the ellipse and added a new script and named it moveAndTest.
The ellipse has to choose a direction in a random order, but keep the direction in square angles:

How to get function tiles in Etoys (e.g. random function)
Get the random number tile by clicking on the icon right of the ticking/paused indicator.

And the distance to move:


The ellipse now will move forward in a random direction in steps of distance 20.

Then there was time to do some testing:

First if the ellipse obtrudes, if it goes out of it's playfield,
that is not wanted.


This moves the ellipse back and starts the search for a random direction again.


... more explanations and instructions upcoming .....

Perhaps also of interest:

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.