The wanderers II

A turtle who goes about straight, but can be teleported by unknown entities.

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(0.25);

// Global code will be evaluated once.
const turtle = new Turtle();

let threshold = 0.9;    // min = 0 max = 1 step = 0.01
let maxDistance = 5;    // min = 0.2 max = 10 step = 0.1
let maxAngle = 90;      // min = 1  max = 90 step = 1
let limit = 10000;      // min = 1000 max = 100000 step = 10

// The walk function will be called until it returns false.
function walk(i) {
    if(Math.random() > threshold){
        turtle.up();
        turtle.goto(Math.random() * 200 - 100, Math.random() * 200 - 100);
        turtle.setheading(Math.random() * 360);
        turtle.down();
    }
    
    turtle.forward(Math.random() * maxDistance);
    turtle.right(Math.random() * maxAngle * 2 - maxAngle);
    return i < limit;
}