Correct code but not winning - boulder woods


#1

Whats wrong with my code?
I used the correct code. angle / 4 is better than angle / 2.
Oh by the way, here’s my code:

loop {
      var angle = Math.PI / 2 - Math.PI / 16;
      while(angle >= -Math.PI / 2) {
          var targetX = this.pos.x + 5 * Math.cos(angle);
          var targetY = this.pos.y + 5 * Math.sin(angle);
          if(this.isPathClear({x: 76 ,y: 35}, this.pos)) {
               this.move({x: targetX, y: targetY});
          }
          else {
              angle -= Math.PI / 4;
          }
      }
}

#2

One major problem is that you are checking if the path is clear from a fixed position and not from where you actually are. You might look a little closer at the if statement.

I’m fairly certain that I used an even smaller angle…