In Advent of Code, we often need to deal with different types of coordinate systems.
This one page explainer has a good illustration on how to navigate hexagonals:
If hexagon is north-south instead of east-west like in picture, rotate one rotation to left (so x axis becomes level)
How to calculate the next coordinate in Python:
from collections import namedtuple
Location = namedtuple('Location', ['x', 'y', 'z'])
def step(current, direction):
match direction:
case 'n':
return Location(current.x, current.y + 1, current.z + 1)
case 'ne':
return Location(current.x + 1, current.y + 1, current.z)
case 'nw':
return Location(current.x - 1, current.y, current.z + 1)
case 'sw':
return Location(current.x + 1, current.y, current.z - 1)
case 's':
return Location(current.x, current.y - 1, current.z - 1)
case 'se':
return Location(current.x - 1, current.y -1, current.z)