Is this considered a gradient descent algorithm?

float Xpos, Ypos, alpha, Xvar, Yvar;

void setup() { alpha = 10;

size(860, 540); Xpos = random(width); Ypos = random(height); background(0); }

void draw() {

stroke(255); strokeWeight(2); point(Xpos, Ypos); stroke(0, 0, 255); point(width/2, height/2); Xvar = width/2 - Xpos; Yvar = height/2 - Ypos; if(abs(Xvar) < 0.1 && abs(Yvar) < 0.1) { Xpos = random(width); Ypos = random(height); } Xpos = Xpos + (Xvar / Xpos) * alpha; Ypos = Ypos + (Yvar / Ypos) * alpha; //I know the alpha isn't alpha it just makes it go much faster

}

Tagged:

Answers

Sign In or Register to comment.