Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/langtons-ant/oracle.py # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / langtons-ant / oracle.py` 21 lines ยท 937 bytes Raw Blame History 1 # Independent reference for "Langton's ant" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 # the black cells as a set; the heading as a complex number (up = -1j with rows growing downward) 4 black = set() 5 pos, head = complex(50, 50), -1j # real part = column, imaginary part = row 6 steps = 0 7 while 0 <= pos.real < 100 and 0 <= pos.imag < 100: 8 if pos in black: 9 head *= -1j # left turn 10 black.remove(pos) 11 else: 12 head *= 1j # right turn 13 black.add(pos) 14 pos += head 15 steps += 1 16 print("steps until the ant leaves the grid:", steps) 17 rows = [int(p.imag) for p in black] 18 cols = [int(p.real) for p in black] 19 print(f"black cells, rows and columns {min(rows)}..{max(rows)} {min(cols)}..{max(cols)}") 20 for r in range(min(rows), max(rows) + 1): 21 print("".join("#" if complex(c, r) in black else "." for c in range(min(cols), max(cols) + 1)))