Squeak
  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:04 pm UTC on 23 June 2018
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 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 upcoming Squeak 5.2 release.

Maze_generated_with_Etoys.png




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:


Etoys_Tile_Ellipse_turn_by_90_multiplied_by_random_4.png
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:

Etoys_Tile_Ellipse_forward_by_20.png


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.

Etoys_Tile_Ellipse_s_obtrudes_Yes_forward_by_minus_20.png

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


Etoys_Maze_construction_Ellipse_moveAndTest_script.png

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




Perhaps also of interest:
http://scratch.mit.edu/projects/nevit/684432

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