#Question about Flee vs. Seek in Nature of Code 2

1 messages · Page 1 of 1 (latest)

kind grove
#

Hello people. I’m following the Nature of Code 2 video about Flee (https://editor.p5js.org/codingtrain/sketches/v-VoQtETO) and I’m having some confusion about the following part of the code in the definition of the class Vehicle:

return this.seek(target).mult(-1);
}

seek(target) {
let force = p5.Vector.sub(target, this.pos);
force.setMag(this.maxSpeed);
force.sub(this.vel);
force.limit(this.maxForce);
return force;
}```

I think conceptually the “flee” function is supposed to make sure that the desired velocity of the vehicle points away from the target, therefore the flee desired velocity = seek desired velocity * (-1), correct? But seems in the code above rather it is the steering force that is being flipped instead by the *(-1)…I don't think they are equivalent. Is my thinking correct? Appreciate your input as always 😉
#

Question about Flee vs. Seek in Nature of Code 2

autumn storm
#

Your thinking is absolutely correct, in that the Dan's implementation of Flee does not match that proposed in the paper, and in some sense can be said to be "incorrect".

#

Dan did a live stream addressing this mistake: https://www.youtube.com/watch?v=zC8GcS6-kNQ
Relevant timestamps: referring to the mistake at 21:40 to 24:30 and the main discussion on the problem is 49:40 onwards

To learn more about Brilliant, go to https://brilliant.org/CodingTrain and sign up for free. The first 200 people that go to that link will get 20% off the annual Premium subscription.

🚂 Website: http://thecodingtrain.com/
💬Discord: https://discord.gg/hPuGy2g
💖 Membership: http://youtube.com/thecodingtrain/join
🛒 Store: https://standard.tv/cod...

▶ Play video