I’m trying to tell my ship to move to a specific coordinate that is immediately adjacent to it’s current position and am failing…I know I must be missing something obvious.
Here’s my approach and understanding: I start with ship.position.get_surrounding_cardinals() and get a list of Positions. I loop though the positions to find the one I want (in this case, the shipyard), and then I want to move the ship into the shipyard (Not using naive_navigate because I want to collide if applicable). However, ship.move requires a cardinal direction, not a position.
How do I convert my position into a cardinal direction that I can use with ship.move? I’ve tried Direction.convert() but I get an error indicating my tuple doesn’t have an x variable.
Code that I thought would work is below. I’m using Python.
surround = ship.position.get_surrounding_cardinals() for sur in surround: if game_map[sur].has_structure and game_map[sur].is_occupied: return Direction.convert(sur)
I’m open to alternative approaches and forehead slapping corrections to my code. Thanks.