StarOS: lidar

Part lidar, 1 port. It reads the snapshot taken at the start of the turn. A rock does not hide what is behind it. See the overview.

member meaning
lidar.range 5 cells (Chebyshev distance)
lidar.scan() every in-bounds cell in range, your own excluded
lidar.probe(direction) the first obstacle along a direction

A scan cell is a dict: dx, dy, x, y, terrain, walkable, robot (a name or None), structure and blocked_by (a building kind, train, hauler, or None). Ground pieces such as cables, belts and track are not obstacles and are not reported.

A probe is a dict: distance, kind (clear, terrain, structure, robot, edge) and name. With clear, distance is the range.

A powered jammer on an enemy robot hides it from your lidar when it is within 5 cells.

def tick():
    ahead = lidar.probe("east")
    if ahead["kind"] == "clear" or ahead["distance"] > 1:
        robot.move("east")