We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
}
Answers
@DominicMann --
Please format the post above by editing it, highlighting your code, and pressing CTRL + o to indent it by four spaces (which will make it readable and preserve line breaks).
Regarding your question:
https://en.m.wikipedia.org/wiki/Gradient_descent#Computational_examples