Langton's ant: Difference between revisions

Content added Content deleted
(Python)
Line 274: Line 274:


i = 0
i = 0
while i < nsteps and x >= 0 and y >= 0 and x < width and y < height:
while i < nsteps and 0 <= x < width and 0 <= y < height:
turn = Turn.left if M[y][x] == Color.black else Turn.right
turn = Turn.left if M[y][x] == Color.black else Turn.right
M[y][x] = Color.white if M[y][x] == Color.black else Color.black
M[y][x] = Color.white if M[y][x] == Color.black else Color.black