Squeak Programming Practice
Fall 2005

  1. Open the "Bot Browser" window.

  2. Type in this new method for your mymethod category:

  3. Run the above method wandering which takes 1 parameter, n, representing how many times to "wander"

  4. Define another wandering method that has an additional parameter for the max angle turn:

  5. Run this new method with various maximum angle turns:

  6. Add the ability to randomly turn right or left:
    
    wandering: n maxAngle: angle
    	"Make the robot walk a random distance and turn through a 
    	random angle n times."
    
    	| left |
          
             . . .
    	 
    	 left := 2 atRandom.
    	 left = 1
    	 	ifTrue: [ self turnLeft: ... ]
    		ifFalse: [ self turnRight: ... ]
    
    	 . . .