[Java] How to get the entity at a position


Is there a method to return the entity on a specific location?


Yes - game.map.at(position).ship, or game.map.at(position).structure. Each is null if there isn’t a thing there.


@teccles I’ve always wondered how you are able to swap the location of two adjacent ships? Thanks for your help


You can’t while using the naive_navigate function. But if you stop using that, you can put commands in your list which move each to the other’s position.


I make another for example 32x32 array, and store where each ship is, and where they would like to go, then search for swaps. Next search for ships that want to move into empty cells, and continue until everyone has moved where they want to or else are stuck in the same position. That way you can just delete the naive_navigate function.

On a more advanced topic, wonder if maybe this can be done look ahead 2 turns to prevent traffic jams. If a 1000 halite ship is returning, everyone should stay out of its way and continue farming an extra turn.


Thanks. 2d arrays are a pretty cool idea. Thanks again!