ACS-1805 Lab 7: Randomness in Alice Nov 7, 2008
This lab uses Alice’s built-in random functions. You must hand in this sheet and the code requested
(see the last line on this page)
Student number ____________________________________________
____________________________________________ Last name
1. Goldfish example a) Tips & Techniques 6 discusses random motion using a goldfish in a water world. The opacity of the water should be 30%. Create this world and the method goldfish.randomMotion. Create an event for your world so the viewer can control the camera (the fish may swim out of view). Run the method using a loop that is executed indefinitely. Demonstrate this to your lab demonstrator. b) Create a similar world-level randomMotion method that has an additional parameter: the object that is to move randomly. Add another goldfish to your world and arrange that both swim in a random motion at the same time. Demonstrate to …
2. A random walk for a (he)/(she) builder object c) A (he)/(she) builder object includes a number of methods developed by a 3D Model developer.
Notice though that when one of these objects is walking, the distance covered is zero meters. Write a method moveObject that makes the object appear to walk for a period of timeDistance seconds while at the same time covering a distance of timeDistance meters. d) Create a method that sends your (he)/(she) builder object on a random walk and demonstrate ...
There are two aspects of randomness. At regular intervals you must i.
randomly choose a time/distance to travel of 1, 2, or 3 seconds/meters (each value 1, 2, 3 must have equal probability of being chosen) ii.
randomly choose a direction: left, right, backward, or forward with respect to the object’s orientation at the time (directions must have equal probability of being chosen)
Pseudocode:
Repeat indefinitely
Choose a time/distance X
Choose a direction
Turn the object so the object is facing the chosen direction
Call moveObject with timeDistance = X iii.
You must export this code for printing, print the page(s), and hand in with the lab .
1/1