I just noticed that when I change the last line in the code fragment from potential =+ rep_pot to potential = potential + rep_pot, I get completely different behaviour. Has anybody got any idea why this is happening?
double potential = euclideanDistance(i, goal);
for (IntPoint h: hits){
double dist = euclideanDistance(i, h);
double a = range - dist;
double rep_pot = (Math.exp(-1/a)) / dist;
potential =+ rep_pot;
}
Yes, because these two things are not equivalent.
Here we have potential assigned a value of the expression ‘unary plus rep_pot’
The thing you intendet to write looks differently:
And this is equivalent to