def path_dir(path):
    """Converts the space coordinates given by pathfind into movement directions (0:N, 1:E, 2:S, 3:W)."""
    commands = []
    for k in range(0, len(path) - 3, 2):
        if path[k] > path[k + 2]:
            commands += [0]
        elif path[k] < path[k + 2]:
            commands += [2]
        else:
            if path[k + 1] > path[k + 3]:
                commands += [3]
            elif path[k + 1] < path[k + 3]:
                commands += [1]
    print(commands)
    return commands