Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Langton's ants

Name: Anonymous 2012-02-18 21:45

http://pastebin.com/eAyjYV1f

I know it's horridly ineficient but I'm having to must fun playing with it to do anything about it.

Have fun

Also, it's called ``Improved langton's ants'' because this is a more modular version of one I made earlier.

Name: Anonymous 2012-02-19 10:50

steps = 10500
lattice = {}
x, y = 0, 0
dx, dy = -1, 0
xmin, xmax = -30, 30
ymin, ymax = -30, 30

for i in range(steps):
    # Flip value
    value = lattice.get((x, y), False)
    lattice[x, y] = not value
   
    # Turn and move
    dx, dy = (dy, -dx) if value else (-dy, dx)
    x, y = x + dx, y + dy

for y in range(ymin, ymax):
    out = []
    for x in range(xmin, xmax):
        value = lattice.get((x, y), False)
        out.append('  ' if value else '[]')
    print ''.join(out)


Why are you using an inferior programming language?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List