Alice LogoAlice Tutorial


Acknowledgements

Copyright ¿ 1998 Carnegie Mellon University. All rights reserved.
We hereby grant permission for any third party to make copies of this tutorial for personal and educational purposes. This tutorial may not be sold for profit without express written permission from the authors, with the sole exception of charging a nominal fee to cover the costs of reproduction.
Image4.gif (1614 bytes)
Alice was created by the members of the User Interface Group of the University of Virginia (Randy Pausch, Director).  Alice development continues by the Stage 3 Research Group located at Carnegie Mellon University.


Introduction

What Alice IS:

What Alice is NOT:

Tutorial Sections

The tutorial is divided into three parts:


Tutorial Part 1: Getting Started With Alice

How To Start Alice

Start Alice by double clicking on the Alice icon on your Windows desktop.  If you can't find the Alice icon, look for Alice99.exe under c:\Program Files\Alice99.  If you still can't find it, use the Windows "Find..." utility.


The Alice Control Panel

This is the Alice control panel.  We will use the menus and buttons on this tool to control the 3D world we are going to create.

The Camera Window

 
And this is the Camera Window.
The camera is looking at a green lawn and blue sky.

Where We’re Headed…
 
The first world we will create has a pink bunny and a helicopter. We’ll make the bunny’s head look at the helicopter. When you’re done, your world should look something like this:
We will make this world one step at a time. 


Loading A World

Let’s start by loading a world into Alice.
Go to the File pulldown menu and choose Open World:

This brings up a dialog box that will let you choose one of the worlds that comes with Alice.

Opening BunnyWorld

 
First click on Examples…
Then select Example1 - FirstWorld and click OK.

Using the Mouse


Use the mouse to move the bunny around.

Then, try clicking the undo button.

Now put the bunny in the middle of the screen like this.

Alice Commands

The mouse is good for quick sloppy placement. For precision, you can type into Alice’s Command Box.
Let's try the move command.  Click into the command box and type this:

bunny.move(forward, 1)

After you type a command, press Enter on your keyboard or use the mouse to click the Go button.


More Move Commands

Next try this…

bunny.move(back, 1)

BEFORE you type the next command: guess what the bunny will do - move to YOUR left or ITS OWN left?
OK, now try this:

bunny.move(left, 1)

Was your guess correct?


Directions of Motion

 

Objects in Alice can move forward, back, left, right, up, and down.

The six directions refer to the object in motion: the bunny moved to its own left, not ours.

Hint: to figure out what direction an Alice object will move, put yourself in that object’s place and use your own sense of left/right and forward/back to "act out" the motion you want.


The Turn Command

Backspace over everything…

 

... and type this:

bunny.turn(left, 1/4)

Again, the bunny turns to its own left, not ours.
The turn command requires two bits of information:

Finally, try these:

bunny.turn(forward, 1)

bunny.turn(right, 1/4)


Let’s Make A Mistake

Alice is very fussy about what you type. Let’s see what happens when we make a mistake.
Try typing this incorrect Alice command. Type it exactly as shown, misspelling the word turn as turb.

bunny.turb(right, 1/4)

You will see this dialog box:

Click OK to dismiss the box.  For a list of other common errors, and what causes them, see the Common Errors section of the tutorial.


Adding Objects

Let’s get the other object for our little project: a helicopter.

Go to the Alice control panel and click on the Add Object button.   This brings up a dialog box that will let you choose one of the hundreds of objects that come with Alice.

Adding The Helicopter

Double click Vehicles...
Double click Helicopter.mdl...


Position The Helicopter

Use the mouse and the command line to move the helicopter and the bunny around so that your world looks something like this:

Hint: holding down the shift key lets you move objects up and down with the mouse.

New Command: PointAt

Now try a new command: the pointat command:

OH NO!

Is this what we wanted?  Not really.

Press the button.

Let's find out how to point the head without turning the body. 


Objects Have Parts

Alice objects have parts, and these parts can have parts, and so on.  This list shows all of the objects in the scene.
Click on the plus sign (+) to see that the bunny has parts called bunny.body, bunny.head, and bunny.drum.

Does bunny.body have parts?


Using Commands With Parts

The name of an object’s part is just the name of the object, followed by a dot, followed by the part name (object.part)
Try these:

bunny.drum.move(down, 0.15)

bunny.drum.turn(forward, 1)

If you miss it, try running it again:

Now let's use the pointat  command on the bunny's head.


Pointat Command With The Bunny’s Head

Try this:

bunny.head.pointat(helicopter)

Now the right thing happens.  The bunny's head turns to point at the helicopter.

Now For Some Real Fun

 Point at the bunny with the mouse and CLICK the right button.

Select Destroy.
If you want to bring the bunny back, press .


End Of Part One: Summary

Here’s a recap of what we’ve just covered:

object.move(direction, distance)

object.turn(direction, revolutions)

object.pointat(another_object)


Tutorial Part 2: Creating Worlds in Alice

 
Before You Start

Do you know how to:

If some of these concepts aren’t familiar, you should go back and glance through the first part of this tutorial.


Where Do We Go From Here?
 
So far you’ve learned how to do some simple things in Alice. To do more complex things you need to learn more about Worlds in Alice.

Worlds in Alice have two parts:


Loading a World

Let’s look at a world that’s already been built in Alice to learn more about how worlds work.

Go to the File pulldown menu and choose Open World:
This brings up a dialog box that will let you choose one of the worlds that comes with Alice.

Opening the Snowman World

First click on Examples...
Then select Example 9 and click OK.

The Opening Scene Tab

An Alice world has two parts:

WORLD = Opening Scene + Script

The Opening Scene and Script tabs in the Alice control panel give you access to the two parts of this world.


What Is An Opening Scene?

Think of an Alice Opening Scene like you would a play’s opening scene: the stage is set, the actors are in place, but the action has yet to begin.   The opening scene of the world you loaded contains a snowman, a snowwoman, and an oven.

The Script Tab

Clicking on the script tab opens the script editor.


What Is A Script?

An Alice script is like the script for a play. It describes the action that will take place. In Alice, a script is a collection of Alice commands that tell the objects in the world what to do and how to do it.  The script for this world moves the snowman forward 1 meter to visit the snowwoman on the right side of the scene.


Performing A Script

Now that you’ve seen the opening scene and script for this world, we want Alice to perform the script.

Make sure the script tab is selected so that Alice is showing the script editor.

Click on the Perform Script button.

Watch the script run!


Performing A Script Twice

Try to guess what will happen if you click Perform Script again after the script finishes.
Try it!
  
Were you right?

What's Going On Here?
Every time you click on Perform Script, Alice resets the world to the Opening Scene before performing the script.


Doing Something Different

After running the script, the world should look like this:

What if we decide that the snowman should go toward the oven to get dinner for the snowwoman?  We'll need to change the world.

How To Change The World

Worlds in Alice are easy to change. Changing either part of an Alice world yields a new and different world.


Changing The Opening Scene

Let’s change the opening scene. Our snowman decides to bring dinner from the oven to the snowwoman, so he needs to move to the oven.
Click on the Opening Scene tab.

Turn the snowman to face the oven.  Hint:  You can do this with the command box or the controls that say "The mouse...".

Your opening scene should look like this.


The Brave New World

What do you think will happen if you perform the script now?

Remember that because you didn’t change the script the snowman will perform the same action.
Try it and find out!
Switch to the script tab and click .
Did the script do what you expected?


Changing The Script

Now let’s change what happens in the world so that the snowman opens the oven door after he moves forward. To do that, we need to change the script.

Adding this new action requires adding a single line to the script:

Perform the script and see what happens.


What Happened?!?

OH NO!! WHAT HAPPENED HERE?

Commands Start At The Same Time

Alice performs all the commands in a script at the same time:

The script starts the snowman moving and  the oven door turning at the same time.  We need a way to tell Alice to perform one command after another.

What we need is a DoInOrder command.


The DoInOrder Command

The DoInOrder command takes a list of commands that should be performed in order (one after another).

Here’s how it looks:

DoInOrder( 
command, 
command, 
command 
)

Using the DoInOrder Command

The two actions we want to perform in order are moving the snowman and turning the door. You need to put these commands inside the parentheses for the DoInOrder command.

Wrap a DoInOrder command around the two existing commands in your script.
Check your work.  Did you put the parentheses and commas in the right place?
Perform the new script.


Very Nice!

Congratulations! The snowman should have moved to the oven. When he arrived at the oven, the door should have opened. This is much better.


The Resize Command

That oven is hot! When he opens the oven door our snowman will be exposed to a blast of heat and he’ll start to melt!
How can we make him melt? One way is to use the Alice Resize command. The Resize command makes an object larger or smaller.
Here’s how it looks:

snowman.resize(amount)

The amount specifies how much to change the size.  For example, you can make the snowman twice his current size or 1/4 his current size.


Making The Snowman Melt

We want the snowman to melt after the oven door opens, so you need to put the Resize command last in your DoInOrder command.
Your script should look like this:

Click on Perform Script and watch it go!


Congratulations!

 

You've learned that Alice worlds contain:

  • what the world looks like (the Opening Scene)
  • what happens in the world (the Script)

and you've learned how to change an existing world.


What Comes Next…
You’re ready to learn how to create your own world from scratch. For this world, we’re going to teach a cement truck to act like an inchworm whenever you click on it with the mouse.


Making A New World

You need a fresh, clean world to start with, so select New World from the File pulldown menu.

Alice will create a new world for you and show you the (empty) opening scene.


Setting Up The Opening Scene

You want your opening scene to look like this:

Use the Add Object button to add the CementTruck to the scene.
Use the mouse and the command line to position it.

Writing The Script

The next step is to write the script to tell the truck how to act like an inchworm.
To do this, you’ll need to use Alice’s Resize command with the FrontToBack and LikeRubber details. Alice will tell the cement truck to resize lengthwise and squash and stretch like a piece of rubber does.

Try this script to squash the truck to half its current length:


Stretching Our Truck Back

Once an inchworm has scrunched up, it needs to unscrunch.
Because we squashed the truck to half its length, to get the truck back to its original length we need to stretch it to twice its current length (2 * © = 1).

This script will first scrunch and then unscrunch the truck:


Hmmm, Something Is Missing

The truck scrunches and unscrunches, but it doesn’t move forward. When an inchworm unscrunches it also moves forward.
But how do we tell the truck to move forward at the same time as it unscrunches?
The answer is Alice’s DoTogether command.


The DoTogether Command

The DoTogether command takes a list of Alice commands to perform (just like the DoInOrder command). However, the DoTogether command performs all of the commands in the list at the same time.
Here’s how it looks:

DoTogether( 
command, 
command, 
command 
)

Using The DoTogether Command

We want the car to scrunch and then unscrunch and move forward at the same time.
To do this we’re going to need:

Can you see how to write this script in Alice?  Try it!


An Improved Inchworm Script

Here’s what your script should look like:

Did you figure it out?  Perform the script and see if it works!


Naming Commands

Our script is getting crowded!
You can assign names to commands in Alice and then use that name instead of the command.
Assigning a name looks like this:

name = command


Using Names In Your Script

Let’s clean up the script by naming some commands and using those names in the script.
 
Doesn't that look better?  Make sure to click on Perform Script to see if the script still works!


Looping A Command

We’ve gotten the cement truck to perform the inchworm command once. What about making the inchworm command repeat?  You can do this in Alice using the Loop command. When a command is looped it starts over again as soon as it finishes.   Here’s what it looks like:

loop(command, number) 
loop(command)

Looping The Inchworm Command

Let’s make Alice perform the inchworm command 4 times. You just need to add one line to your script to make this happen:


Click on Perform Script and count the number of repetitions.
Did the truck inchworm 4 times?


Making Your World Interactive

Now let’s make your world interactive so that the cement truck inchworms when you click on it with the left mouse button.  We'll need Alice's RespondTo command to do this.

The RespondTo Command

The RespondTo command tells Alice what to respond to and how it should respond.
The command looks like this:

Object.RespondTo( WhatToRespondTo, HowToRespond)

Reacting To Mouse Clicks

We want the cement truck to respond by performing the inchworm command we’ve built when you click on it with the left mouse button.
To tell Alice to do this we need to remove the loop command and add a RespondTo command. Your script should look like this:


Your Interactive World

Your world should be ready to go!
Click on the Perform Script button to try it out.
Does clicking on the truck do the right thing?


End Of Part Two: Summary

Here’s a recap of what we’ve covered in this part of the tutorial:


Tutorial 3: Adding Details to Commands in Alice

 Before You Start

Do you know how to:

If some of these concepts aren’t familiar, you should go back and glance through parts 1 and 2.


Where Do We Go From Here?
 
You’ve learned how to create worlds in Alice and structure commands so that they happen in order or together.  To do more complex things in Alice, you need to know how to put more detail into the commands you give to Alice.


Loading An Example World

For the first part of this tutorial we’re going to use a pre-existing world.


Spinning the Windmill’s Blades

You should now see a windmill in the camera window, like this:


In the script editor (click on the Script tab), you should see this:


The Blades Move Too Fast

Click on the Perform Script button.
WHOOSH!
The blades spin around rather quickly, don’t they?

We probably want to slow them down.

Remember that all animations in Alice normally take 1 second.  If you want something to take more time (or less time) you can use a special word, Duration, inside the Roll command.


The Duration Keyword

Try this:

Click Perform Script

The blades now take 3 seconds to turn completely around, because we gave the roll command more details on how we’d like it to behave.

Duration is an example of a Keyword. Keywords are optional words that go inside Alice commands that make the basic command do more interesting things. Look at the end of this tutorial for a Keyword List.


The Speed Keyword

Instead of using the Duration keyword to specify the amount of time the blades take to spin around, you can use the Speed keyword to make the blades spin at a certain speed. Try this:

The blades spin around once at a speed of 1/3 rotations per second.


Adding An Object To The Scene

Let’s put a horse into the scene in order to demonstrate another keyword.
Click on the Opening Scene tab, and use the Add Object button (the horse is in the Animals directory). You want your scene to look like this:


Moving the Horse Forward

We can make the horse move forward using the Move command (remember this command from Tutorial 1?). Click on the Script tab, and change your script to look like this:

Click Perform Script.

The horse moves forward.


The AsSeenBy Keyword

However, using the AsSeenBy keyword, we can make the horse move in the windmill’s forward direction. Add AsSeenBy to the command in your script, like this:

Click Perform Script.

The horse moves in the windmill's forward direction.


Why Use AsSeenBy

Other commands in Alice understand AsSeenBy, allowing you to do more interesting things. For instance, you can make the horse run around the windmill. Try changing move to turn, and forward to right, like this:

The horse runs around the windmill once.

The horse is actually turning right, as seen by the windmill.


Keywords Summary

Here’s a summary of what we’ve learned so far:
Some commands in Alice understand keywords like Duration, Speed, and AsSeenBy. Keywords allow you to do more interesting things by giving commands more specific details. In the back of this tutorial is a list of other keywords that Alice recognizes.
Now we’ll load a new world that will help you learn another way of giving details to commands in Alice.

From the File pulldown menu choose Open World...

Double-click on Tutorials, and then double-click on Watching.
You should see this:


PointAt Revisited

Click on the Script tab. You should see:

Click Perform Script.

The bunny looks at the helicopter. However, this animation only happens once; the bunny will not continue to look at the helicopter if we move the helicopter.
Use the mouse to drag the helicopter around to see that this is the case.


The EachFrame Token

To make the bunny continue to look at the helicopter, we want to tell the PointAt command to continue to happen as often as possible.

To do this, we can use a special word: EachFrame. EachFrame is a token. Like keywords, you can use tokens to give commands more details. Try adding EachFrame to the command that’s already in the script:

Click Perform Script.

Now drag the helicopter around with the mouse!


Introduction to Control Panels

Sometimes we want to be able to control the worlds we create without having to change the script and without having to drag objects around with the mouse. You can create Control Panels with buttons that the user can press.
Let’s load a world with a control panel in it:

From the File pulldown menu, choose Open World...

Double-click on Tutorials, and then double-click on ControlPanel.

You should see this:


Control Panel with a Label

Click on the Script tab. Your script should look like this:

Click Perform Script.

You should see a small control panel that looks like this:

Unfortunately, our control panel doesn't do anything yet!


Adding a Button

Let’s add a button to our control panel.
Add this command to your script:

Click Perform Script.


A Control Panel with a Button

You should see a control panel that looks like this:

Try clicking the button!


Summary

 
Where To Go For More Help

To learn more about Alice and what it can do, look in the following places:

• The Online Documentation Section

This section contains advice for advanced users of Alice who have completed the full tutorial and are looking for new ideas and challenges.

• The Alice Help Menu

• Mailing list: alice-users@cs.cmu.edu


Keywords That Alice Recognizes

Here is a list of the different keywords that Alice understands. You’ll want to look at the Alice manual to find out which keywords can be used for different commands.

Keyword Values the keyword can be given
AsSeenBy  Any object in the world. You can move and turn AsSeenBy any other object.
Speed Any number. For movement, this number is in meters per second; for turning, this number is in rotations per second.
Style Any of these: Gently, Abruptly, EndGently (or BeginAbruptly), BeginGently (or EndAbruptly) You can use this keyword to describe how you want an animation to start and stop.
Duration Any number, in seconds. You can use this keyword to describe how long you want an animation to take. If you do not use this keyword, all animations normally take one second.
Lifetime Any number, in seconds. For animations that will normally last forever, you can use this keyword to stop them after a certain amount of time.
HowMuch Any of these: ObjectAndParts, ObjectAndChildren, ObjectOnly. You can use this keyword when you are getting information about an object or when you are changing an object’s properties to describe how much of the object you wish to consider/affect.

Common Errors

Missing comma or using a period instead of a comma othererror.gif (5661 bytes)
Misspelled or unknown name for an object (there is no object called fred in our world) nameerror.gif (5720 bytes)
Misspelled or unknown name for a command commanderror.gif (7550 bytes)
Missing parenthesis  othererror.gif (5661 bytes)

Cheat Sheet

Move

Turn

PointAt

Destroy

Using Commands With Parts


The Alice Interactive 3D Graphics Programming System is Copyright ¿ 1997, 1998, Carnegie Mellon University. All rights reserved.
Alice was initially developed at the University of Virginia.