Skip to main content
gnzg's user avatar
gnzg's user avatar
gnzg's user avatar
gnzg
  • Member for 7 years, 10 months
  • Last seen more than 4 years ago
comment
Simulated race among three robots making random steps
I fixed it by slightly changing the if condition inside the forEach function to this: const middleDistance = robot.position - this.middle; and to establish minMiddleDistance: if (middleDistance > 0 && middleDistance < this.minMiddleDistance) Full code: repl.it/repls/ExternalFatalDemands
awarded
awarded
awarded
comment
Simulated race among three robots making random steps
In essence you are right, but how does that code account for the distance specifications?
comment
Simulated race among three robots making random steps
There is no explicit requirement for that, only that each pace is of a random distance. The Math.random() * 100 is just an arbitrary choice I made.
comment
Simulated race among three robots making random steps
That was a concern I had as well... what I ended up doing was generate a new d1 at the very end of the loop (see above) and see if the new distance when added to the current position on the lane would surpass 1km. Hope this provides some clarification.
Loading…
awarded
awarded