Introducing SpiderWorld

Picture of SpiderWorld screen

Spiderworld is a computer simulation in which a robot-like creature, the spider, can be programmed to draw simple graphic patterns. The spider, symbolized by a triangle, lives in a square room, and can be guided via commands entered on the keyboard. The menu box on the left shows in capital letters the keys to which the spider will respond.

DRAWING COMMANDS

Key    Command     Description

S Step Paint the square you are standing on and then move one step forward in
the direction you are facing.
T Turn Turn to the right. (Note: right turn relative to the Spider, not the viewer).
R Red Change to red paint.
B Blue Change to blue paint.
G Green Change to green paint.
K Black Change to black paint (which will "erase" other colors).
M Move Move one step forward WITHOUT painting.


Drawing with the spider

As you press the keys corresponding to the draw commands above, the spider will carry out the corresponding action. The command you enter will also be displayed in the "commands window" on the right side of the screen.

You can clear any picture you have drawn and start over with the Clear command.

The Spider remembers each draw command that you enter. (The commands are displayed in the command window.) When you press Animate the Spider will autonomously carry out those commands, recreating the picture on her own. Animate always begins from first command in the Spider's memory.

The sequence of draw commands shown in the screen photo above has created the picture shown in the spider's room. After finishing, the triangle is pointed north, indicating the direction the spider is facing.


Saving to a disk file

The spider's memory, where it remembers the sequence of commands you type, is called primary memory. It is "volatile," which means it is erased by the Clear command or if you Quit Spider Draw.

The saVe command saves whatever is in the Spider's memory onto a disk file. The disk file is called secondary memory. It is non-volatile. Even if you turn the computer off, the data on the disk is not affected. The spider's memory can be restored from a disk file with the Load command.

The Help command displays a quick reference screen of the spider commands.

Programming the spider

The spider has several more powerful abilities that can not be harnessed simply through drawing. Instead of guiding the spider directly, you create a sequence of commands in a special spider "language" and enter them into a file with a text editor. The Edit command invokes an editor you can use to type in your spider programs. When you exit the editor, the spider will carry out the commands in the program, drawing the picture on the spiderworld screen.

The Spider Language



-- Remarks which follow two are comments for human readers.
Reset; -- Clear the spider's screen and start over in the middle.
Start; -- Reset with a random sized room, placing the spider in upper left corner, facing east.

WHILE NOT AtWall LOOP   -- WHILE defines a sequence of statements ("body") which is repeated
... body of loop                         -- until the spider reaches a wall.
END LOOP;

PROCEDURE name IS     -- PROCEDURE defines a name for a group of statements which
BEGIN                 -- perform some task. Placed at the beginning of a program, you can
... body of procedure      -- later use that name when you want the spider to do that task.
END name;



-- A Sample Program with LOOPs


WITH Spider; USE Spider;
PROCEDURE sample1 IS
BEGIN
Start;
Red;

-- This loop paints a line
-- across the room
WHILE NOT AtWall LOOP
Step;
END LOOP;

-- and then one blue square
-- at the end
Turn;
Blue;
Step;
Quit;
END sample1;


-- A Sample Program with PROCEDUREs

WITH Spider; USE Spider;
PROCEDURE sample2 IS

-- Define a new command "Left" turn
PROCEDURE Left IS
BEGIN
Turn;
Turn;
Turn;
END Left;

-- Define a new command "Hop"
PROCEDURE Hop IS
BEGIN
Step;
Move;
Step;
END Hop;

BEGIN -- the main program invokes the new commands
Reset;
Turn;
Hop;
Left;
Move;
Hop;
Left;
Move;
Hop;
END sample2;




© Copyright 1998 John Dalbey