Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 30th, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import Turtle.SimpleTurtle;
  2.  
  3.  
  4. public class DrunkTurtle extends SimpleTurtle {
  5.        
  6.         public void moveForward (double distance){
  7.             for(int i = 0; i < 4; i++){
  8.               if(Math.random()*10 < 5){
  9.                 super.turnLeft((int)Math.random()*60-30);
  10.              
  11.               }
  12.               else{
  13.                 super.turnRight((int)Math.random()*60-30);
  14.                
  15.               }
  16.               super.moveForward((Math.random()*2*distance)/7);
  17.             }
  18.           }
  19.        
  20. }