How can I get my Shipyard position


#1

Can anyone tell me how to get the position of my shipyard and then send a ship to return the cllected halite? I know this is a very basic question, but I am struggling to find out simple things, only using logging.info() without any live debugging.


#2

You shipyard should be at game.me.shipyard.position


#3

Thank you Daniel! Is there also a way to store some kind of a route, like a list of positions, representing a certain path to have a ship get to the shipyard? I know that there are distance functions, but are there also some pre built pathing functions or do I have to build a path by myself?

It could be useful to use it as an intial navigation plan for a ship, which might be updated at every turn, as a reaction to the most current game_map and positioning information.


#4

You could but I advise against this since the route to your shipyard will be changing every turn since you’ll have your own ships in the way, enemy ships, and halite in the way.


#5

@topperwithharley The simplest way is to just move toward the shipyard each turn, and not look ahead. With a Manhattan grid like we are playing on, there is almost always two directors that will get you equally closer to your goal. Just pick one of those two that won’t have any other ships in it at the end of the turn.

Here’s a much better way to not collide with things:

  • At the start of each turn, have a boolean array, with one boolean per map cell. Have all marked false.
  • Mark any enemy ship’s cells as true, unless they are 1 or closer to your shipyard or drop off.
  • Go through your ships and find any that can’t move due to fuel reasons. Mark those squares as occupied.
  • Whenever you issue a move command to a ship, mark the cell they are going to as occupied.
  • Then always check this before moving into a square.

Now you can always avoid collisions with your own ships and your own ships can swap positions with each other at will.


#6

One thing to add to that list:

Sort and prioritize your ships before you iterate through and choose moves.

Reason: sometimes you have a cluster of ships and then it becomes a game of musical chairs. One ship will be left standing without a place to land. In that event you’ll need to find a sucker to step on, hopefully it’s an enemy ship.

This could be mitigated by re-moving the ships that are in the way but if you want quick and dirty, that’s the way to go.


#7

Thanks for the valuable advises guys. Maybe I’ll come up with further related questions after another sweat session with my current Bot. :slight_smile: