Does naiveNaviate suck? I should just create my own pathfinding right?


#1

I’m a high school Comp Sci student, and I started on this competition with a group of friends when my teacher recommended it to me.

I have made pretty good progress so far, but a problem that I seem to have is with the naiveNavigate method in the starter code. Logging the directions that it outputs, it seems that its often times just random, and not the most efficient path to the destination. I have removed all of the “unsafe” marks from the gameMap in my code, and it still seems to often output a random direction, rather than the optimal direction. Would I be better off just creating my own function?


#2

What you mean by “random”? This is determined function, it will return the same output for the same game state. If your target is diagonally from your ship then it returns first free direction selected from two (x-axis direction and y-axis direction).

There is no “optimal” direction or path from the box. Just safe/unsafe.

Also naiveNavigate can not handle ships swaps so you have to create your own navigation.
P.S.: Check this


#3

I am currently only using naiveNav to go back to the nearest shipyard/dropoff, and to spread away from the shipyard in the early game.

By random, I mean that sometimes where there is a straight path to the destination, the function makes the ship go to the side for sure reason.

Also, when the difference in x coordinates is larger than the difference of y coordinates, you would expect it to first narrow down the x difference, and then when its a perfect diagonal alternate between x and y movements, but this is not the case either.


#4

In this case you could implement A* or some similar algorithm. And just do all collisions cheks manually or by your movement function for regular movement.


#5

A very safe assumption to make is that everything in the starter kit is sub-optimal. :slight_smile:

It’s pretty easy to code your own pathing that correctly handles collisions, avoids logjams, and keeps things moving. It’s the first thing I replaced.