(like adding a “teleport” command, logging moves, visualizing the grid, or handling dynamic obstacles), just let me know.
# Terminus - Part 2: Right-Hand Rule Navigation # Assumes a grid with obstacles (1 = wall, 0 = open) def right_hand_rule_navigation(grid, start, goal): """ Navigate from start to goal using the right-hand rule. grid: 2D list (0=free, 1=wall) start, goal: (row, col) tuples """ # Directions: 0=North, 1=East, 2=South, 3=West dirs = [(-1, 0), (0, 1), (1, 0), (0, -1)] direction = 1 # start facing East activity 4.3.1: terminus - part 2
if (row, col) == goal: print(f"Goal reached in {steps} steps!") return path else: print("Goal unreachable or loop detected.") return None grid_example = [ [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0] ] (like adding a “teleport” command