Beispiel #1
0
def find_manhattan_spheres(rng, c_pos):
    if FAST_SPHERE:
        return manhattan_sphere.find_manhattan_spheres(rng, c_pos[0], c_pos[1])
    else:
        _range = range
        main_set = set()
        for r in rng:
            # Finds manhattan spheres of radius r
            for x in _range(-r, r + 1):
                pos_x = x if x >= 0 else -x
                for y in [(r - pos_x), -(r - pos_x)]:
                    main_set.add((c_pos[0] + x, c_pos[1] + y))
        return main_set
Beispiel #2
0
def get_adjacent_positions(c_pos, rng=1):
    if FAST_SPHERE:
        return manhattan_sphere.find_manhattan_spheres(range(1, rng+1), c_pos[0], c_pos[1])
    else:
        _range = range
        pos = set()
        for r in _range(1, rng+1):
            # Finds manhattan spheres of radius r
            for x in _range(-r, r + 1):
                pos_x = x if x >= 0 else -x
                for y in [(r - pos_x), -(r - pos_x)]:
                    pos.add((c_pos[0] + x, c_pos[1] + y))
        return pos