[00:00] (0.00s)
Ants. I love ants. And I, like many
[00:02] (2.96s)
people that watch this channel, am
[00:04] (4.40s)
probably a little bit awesome, and I
[00:06] (6.88s)
love watching videos of ant simulations.
[00:09] (9.60s)
This video is about my own ant
[00:11] (11.44s)
simulator, but secretly, it's a video
[00:13] (13.68s)
about touring machines. My simulator is
[00:16] (16.64s)
a free website that you can go play with
[00:18] (18.48s)
right now. It was programmed with AI. I
[00:21] (21.04s)
have a full video on how it was made. If
[00:22] (22.80s)
you haven't seen it, then I command that
[00:24] (24.48s)
you go watch it. But the actual
[00:26] (26.40s)
algorithm here was invented by a human
[00:28] (28.64s)
named Chris Lton, an artificial life
[00:31] (31.04s)
researcher that created some of the
[00:32] (32.48s)
coolest things I've ever seen and then
[00:34] (34.32s)
dropped from the field in the '9s. I
[00:36] (36.24s)
hope you're doing well, Chris. You made
[00:37] (37.68s)
some cool stuff. This is Lon's ant. No,
[00:41] (41.76s)
not LinkedIn's aunt. That's a very
[00:43] (43.60s)
different thing. Here's how it works.
[00:45] (45.44s)
The ant lives on a grid of black and
[00:47] (47.36s)
white cells. It moves around on that
[00:49] (49.44s)
grid, changing cell colors as it goes,
[00:51] (51.52s)
like it's leaving pheromone trails. It
[00:53] (53.84s)
has a current direction and depending on
[00:56] (56.00s)
the color of the cell it's currently on,
[00:58] (58.24s)
it decides whether to turn left or right
[01:00] (60.56s)
and how to change the color of the cell.
[01:02] (62.80s)
The rules for Len's ant are if it's
[01:05] (65.12s)
white, change it to black and turn left.
[01:07] (67.28s)
If it's black, change it to white and
[01:09] (69.04s)
turn right. You can invert those colors
[01:11] (71.20s)
or turns however you want and it will do
[01:13] (73.12s)
the same thing. Following these simple
[01:15] (75.20s)
rules, the ant initially seems to move
[01:17] (77.36s)
kind of randomly. Even though this is a
[01:19] (79.20s)
fully deterministic program, at some
[01:21] (81.44s)
point it makes this almost symmetrical
[01:23] (83.28s)
shape, but then continues in a mostly
[01:25] (85.20s)
random pattern. Then after 10,000 steps,
[01:28] (88.80s)
something remarkable happens. It gets
[01:31] (91.04s)
stuck in a loop and builds this
[01:32] (92.96s)
structure out infinitely. This is called
[01:35] (95.36s)
a highway, and it is a classically
[01:37] (97.60s)
emergent structure. In my simulator, the
[01:40] (100.64s)
grid borders wrap around, so it will
[01:42] (102.64s)
eventually collide with itself. It is an
[01:45] (105.44s)
odd and unexpected thing that such
[01:47] (107.92s)
simple rules produce such a mix of chaos
[01:50] (110.88s)
and order. But the reason I made this
[01:53] (113.20s)
simulator is because I wanted to see
[01:54] (114.88s)
what other weird things I can get these
[01:56] (116.72s)
ants to do. Indeed, with real ants,
[01:59] (119.28s)
things get much more interesting when
[02:00] (120.88s)
you have lots of them. So, what happens
[02:03] (123.52s)
if we start with two of Lankton's ants
[02:05] (125.76s)
right next to each other, both facing to
[02:07] (127.68s)
the right? Almost immediately, they
[02:09] (129.68s)
start to kind of work together, building
[02:11] (131.76s)
a border that extends outward forever.
[02:14] (134.80s)
Very unexpected.
[02:16] (136.72s)
Even more interesting, when they
[02:18] (138.24s)
eventually wrap around the edges of the
[02:19] (139.84s)
grid and collide, they can start
[02:21] (141.76s)
backtracking and deconstruct everything
[02:24] (144.08s)
they've built. A weird property of
[02:26] (146.08s)
LinkedIn's ants is that they can
[02:27] (147.44s)
sometimes do this perfect backtracking
[02:29] (149.60s)
deconstruction. When they meet again in
[02:32] (152.16s)
the middle, they start over, and they
[02:34] (154.00s)
will do this forever.
[02:36] (156.80s)
Even weirder, this border building
[02:39] (159.04s)
behavior happens with any even number of
[02:41] (161.28s)
ants all in a row facing the same
[02:43] (163.60s)
direction of the row.
[02:45] (165.72s)
[Music]
[02:50] (170.16s)
It doesn't work for odd numbers of ants,
[02:52] (172.40s)
though. Why? Beats me. It just is
[02:55] (175.60s)
bizarre behavior.
[02:58] (178.40s)
Two ants in a row facing up rather than
[03:00] (180.80s)
to the side get stuck in an infinite
[03:03] (183.12s)
dance. Four of them arranged in a
[03:06] (186.00s)
square, all facing the same direction,
[03:08] (188.08s)
make a little traveling party that moves
[03:10] (190.08s)
endlessly in one direction without
[03:11] (191.92s)
leaving a trace.
[03:14] (194.72s)
Most other configurations just end up
[03:16] (196.80s)
making a mess. That will be a common
[03:18] (198.40s)
theme here. But there is still
[03:20] (200.08s)
unexpected order here. Remember that
[03:22] (202.40s)
these are all just following that same
[03:24] (204.48s)
stupidly simple rule as before. Yet, you
[03:27] (207.12s)
cannot foresee what they will do until
[03:29] (209.36s)
you let them do it.
[03:32] (212.88s)
We can come up with far more complex
[03:34] (214.80s)
behaviors by introducing different cell
[03:37] (217.12s)
colors, different movement types, and
[03:39] (219.36s)
different logic. You can use these rule
[03:41] (221.84s)
string things to encode ant behavior.
[03:44] (224.24s)
They work pretty well, but they cannot
[03:46] (226.08s)
encode all possible behaviors. So, I
[03:48] (228.72s)
just skipped ahead to make a universal
[03:50] (230.56s)
rule set using state machines. I didn't
[03:53] (233.68s)
invent these obviously, but I've set up
[03:55] (235.52s)
my own syntax with a lot of AI help. The
[03:58] (238.24s)
ant's brain is a state machine or a
[04:00] (240.80s)
finite state automaton which is a way of
[04:03] (243.44s)
programming arbitrary logic. You can
[04:05] (245.84s)
think of the state as the ant's state of
[04:08] (248.32s)
mind or its current mode. Its action now
[04:11] (251.68s)
depends on both the color of the current
[04:13] (253.68s)
cell and the state it is currently in.
[04:16] (256.80s)
All of which decides how to move, what
[04:19] (259.20s)
color to write, and what internal state
[04:21] (261.60s)
to change to next. So, it won't always
[04:24] (264.32s)
do the same thing when it's on the same
[04:26] (266.08s)
color because it can be in a different
[04:28] (268.24s)
state of mind. Here is some state
[04:30] (270.56s)
machine logic written as a JSON object.
[04:33] (273.52s)
It has two states and can read and write
[04:36] (276.00s)
two colors, black and white, just like
[04:38] (278.16s)
before. Each state has its own set of
[04:40] (280.64s)
actions for each color. We always start
[04:43] (283.52s)
in state zero, the first one, and we
[04:45] (285.68s)
read black, which is color zero. So, for
[04:48] (288.64s)
state zero, color zero. This is the
[04:51] (291.04s)
action. right color one white move right
[04:54] (294.24s)
and change to state one we are now in
[04:57] (297.20s)
state one the second one so we now
[05:00] (300.00s)
follow these rules we read black again
[05:02] (302.80s)
so state one color zero write black move
[05:06] (306.08s)
right and go back to state zero and I
[05:09] (309.12s)
think you get the idea this is what
[05:10] (310.88s)
happens when you run this logic over and
[05:12] (312.88s)
over and over I have also defined the
[05:15] (315.60s)
special state negative one to be the
[05:17] (317.76s)
halted state where it will permanently
[05:20] (320.00s)
stop the state machine is effectively a
[05:23] (323.20s)
program and the grid acts as the memory
[05:25] (325.68s)
that the program is reading and writing
[05:27] (327.84s)
to by definition. That makes these ants
[05:31] (331.12s)
turing machines only with a
[05:33] (333.04s)
two-dimensional grid memory rather than
[05:35] (335.20s)
the classical one-dimensional tape. We
[05:37] (337.84s)
call them termites spelled with a u in
[05:40] (340.64s)
reference to turing machines and Greg
[05:42] (342.88s)
Turk, one of the guys who originally
[05:44] (344.64s)
invented this paradigm. Termites are
[05:47] (347.28s)
universal with enough states and enough
[05:49] (349.52s)
memory. They can compute any computable
[05:51] (351.92s)
program. They are a visualization of
[05:55] (355.20s)
computer programs in execution. When
[05:57] (357.68s)
they repeat behaviors like this, they're
[05:59] (359.52s)
performing a loop or recursion. Multiple
[06:02] (362.32s)
ants are the equivalent of
[06:03] (363.68s)
multi-threading with many programs
[06:05] (365.76s)
sharing the same memory. As you add more
[06:09] (369.04s)
states and more colors, you explode the
[06:11] (371.92s)
number of possible state color
[06:13] (373.68s)
combinations.
[06:15] (375.20s)
I've artificially limited the number of
[06:17] (377.12s)
colors to 12. There's only so many
[06:18] (378.96s)
distinct colors, but you can randomize
[06:21] (381.04s)
with up to 1,000 states. I've also added
[06:24] (384.00s)
lots of different kinds of movement. L
[06:26] (386.24s)
for left, R for right, U for Uturn, go
[06:29] (389.44s)
the opposite of the current direction,
[06:31] (391.28s)
and N for no turn. Just move straight in
[06:34] (394.40s)
the current direction. These are all
[06:36] (396.40s)
relative moves. They depend on the ant's
[06:38] (398.48s)
direction. But you can also use absolute
[06:40] (400.88s)
moves. North, south, east, and west
[06:42] (402.80s)
denoted with arrow characters. These do
[06:45] (405.60s)
not care about the ants direction.
[06:48] (408.16s)
Finally, there is S for stay, don't move
[06:50] (410.72s)
at all, and question mark for random,
[06:53] (413.36s)
which selects a random absolute move.
[06:56] (416.32s)
The randomize button will randomly mix
[06:58] (418.88s)
and match these movements, colors, and
[07:00] (420.88s)
states to create some very complex ant
[07:03] (423.52s)
behaviors. Typically, they're not that
[07:06] (426.00s)
interesting. Most will just fill up the
[07:07] (427.52s)
grid with noise. But if you just keep
[07:09] (429.28s)
randomizing, you can find some really
[07:11] (431.04s)
interesting ones or manually craft them
[07:13] (433.28s)
yourself. You can save the rule to a
[07:15] (435.28s)
file and load it up later or share it on
[07:17] (437.52s)
my Discord. I'll make a channel for it.
[07:19] (439.84s)
Yes, they can occasionally make some,
[07:21] (441.84s)
let's say, politically charged symbols,
[07:24] (444.08s)
which I am not interested in seeing on
[07:26] (446.00s)
my Discord server. I've saved a bunch of
[07:28] (448.40s)
cool ones in the presets drop down here.
[07:30] (450.40s)
So, let's take a look. I call this one
[07:32] (452.24s)
the constructor. It just makes a neat
[07:34] (454.40s)
spiral pattern and then it keeps
[07:35] (455.92s)
building around in a seemingly
[07:37] (457.52s)
organized, deliberate way for a while at
[07:39] (459.84s)
least. I found it by just randomizing
[07:42] (462.08s)
over and over and over. That's how I
[07:43] (463.84s)
spend my free time. But the others, like
[07:46] (466.24s)
this Archimedes spiral, were discovered
[07:48] (468.32s)
by other people and published online. I
[07:50] (470.56s)
just stole the rule. It was extremely
[07:53] (473.28s)
useful to use AI to reconstruct these.
[07:55] (475.76s)
It's actually kind of the perfect AI
[07:57] (477.44s)
task. It's also a good sanity check that
[07:59] (479.92s)
the program is written correctly, that
[08:01] (481.92s)
the rules are being applied properly. If
[08:04] (484.48s)
they weren't, these patterns would not
[08:05] (485.92s)
just be slightly wrong, they would be
[08:07] (487.84s)
completely wrong. They wouldn't work at
[08:09] (489.76s)
all. Now, while it was a lot of fun to
[08:12] (492.40s)
make this simulator with AI, I do sort
[08:14] (494.56s)
of feel robbed of the experience of
[08:16] (496.32s)
making it myself, of figuring out the
[08:18] (498.32s)
algorithm and crafting the rules. I
[08:20] (500.56s)
don't understand it as well as I would
[08:22] (502.00s)
have if I had made it all myself. Also,
[08:24] (504.40s)
you may have noticed there are little
[08:26] (506.00s)
lingering bugs in this program,
[08:28] (508.16s)
especially visual artifacts that have
[08:30] (510.24s)
been very difficult to iron out with AI
[08:32] (512.64s)
programming.
[08:34] (514.16s)
On the other hand, I probably would
[08:35] (515.76s)
never have made this at all without AI.
[08:38] (518.16s)
It's a give and take, I guess.
[08:41] (521.12s)
Some ants make symmetrical patterns like
[08:43] (523.52s)
this one, which is extremely rare since
[08:45] (525.60s)
the ant must build each symmetrical side
[08:48] (528.16s)
independently. There is no natural
[08:50] (530.64s)
guarantee of symmetry, and even this is
[08:53] (533.20s)
only occasionally symmetrical.
[08:55] (535.84s)
Now, here's an interesting question.
[08:57] (537.84s)
This ant makes a structure that looks
[08:59] (539.44s)
like it's bounded to this small area. It
[09:02] (542.00s)
never grows beyond a certain limit. But
[09:04] (544.40s)
is it actually bounded forever? It
[09:07] (547.28s)
certainly looks like it, but maybe after
[09:09] (549.28s)
a billion billion billion steps, it
[09:11] (551.68s)
starts building a highway like Lton's
[09:13] (553.68s)
ant, or it just continues inching its
[09:15] (555.84s)
way outwards. As far as I can tell, we
[09:18] (558.48s)
don't know the answer to this. Despite
[09:20] (560.32s)
their simplicity, it is extremely hard
[09:22] (562.32s)
to tell what these ants will do.
[09:27] (567.92s)
An especially beautiful one, maybe my
[09:30] (570.00s)
favorite, is this snowflake, which is
[09:32] (572.00s)
also symmetrical almost. It's just a bit
[09:35] (575.04s)
off. You can see that here in the
[09:36] (576.64s)
center. Regardless, it's incredible that
[09:39] (579.12s)
such a thing is possible by building one
[09:41] (581.12s)
cell at a time. Given that these are
[09:43] (583.92s)
universal touring machines, I think it
[09:45] (585.84s)
should be possible to build a perfectly
[09:47] (587.84s)
symmetrical snowflake. But no such rule
[09:49] (589.92s)
has been found. In fact, I think it
[09:52] (592.64s)
should be possible to build any given
[09:54] (594.56s)
image like say a smiley face. This was a
[09:57] (597.76s)
fully AI generated rule. Is it not super
[10:00] (600.08s)
cute? It actually isn't that hard to
[10:02] (602.64s)
write a rule that can make a given
[10:04] (604.32s)
image. It just needs to go cell by cell,
[10:06] (606.80s)
row by row, and lay down the right color
[10:09] (609.28s)
for each pixel of the target image. I'm
[10:11] (611.84s)
pretty sure that would work. Now, to
[10:14] (614.48s)
prove that these ants really are touring
[10:16] (616.32s)
machines, we can build some simple
[10:18] (618.16s)
touring machine programs by simply
[10:20] (620.16s)
restricting the ants movement to east
[10:22] (622.32s)
and west, side to side. We also restrict
[10:25] (625.12s)
the colors to black and white, one and
[10:27] (627.52s)
zero. This simulates the one-dimensional
[10:30] (630.16s)
memory tape that touring machines read
[10:32] (632.16s)
and write from. Theoretically, the tape
[10:34] (634.72s)
should be infinite, which it's not in
[10:36] (636.64s)
this simulator, but you get the idea.
[10:38] (638.80s)
With these ants, we can reconstruct the
[10:41] (641.04s)
so-called busy beaver programs. These
[10:44] (644.00s)
are a bit abstract, so bear with me
[10:45] (645.68s)
here, but intuitively, a busy beaver is
[10:48] (648.48s)
the most complex touring machine that
[10:50] (650.72s)
you can build with a fixed number of
[10:52] (652.72s)
states that will eventually halt. Of all
[10:55] (655.68s)
the programs that don't run forever,
[10:57] (657.92s)
Busy Beavers run the longest. So, take
[11:01] (661.04s)
Busy Beaver 3. Its state machine has
[11:03] (663.52s)
only three states and it runs longer
[11:05] (665.52s)
than any other three-state program
[11:07] (667.68s)
before eventually halting. There are
[11:10] (670.00s)
plenty of three-state programs that run
[11:11] (671.68s)
forever, but they don't count. A Busy
[11:13] (673.84s)
Beaver must eventually halt. Busy Beaver
[11:16] (676.88s)
4 looks like this. It has four states
[11:19] (679.36s)
and runs for 107 steps. And here is the
[11:23] (683.52s)
recently discovered Busy Beaver 5. It
[11:26] (686.24s)
runs for 47,176,870
[11:31] (691.20s)
steps before halting. It's actually so
[11:34] (694.16s)
complex that it cannot run properly
[11:35] (695.92s)
here. It's too big and it overlaps with
[11:38] (698.08s)
itself. Busy Beaver 6 is unknown and
[11:41] (701.36s)
probably will be forever. The search
[11:43] (703.20s)
space becomes enormous and the candidate
[11:45] (705.28s)
programs run for far far far too long.
[11:48] (708.72s)
Maybe I'll make a video on busy beavers
[11:50] (710.64s)
in the future. I definitely want to make
[11:52] (712.32s)
something about Turing completeness.
[11:54] (714.16s)
expect that in the year 2079.
[11:57] (717.52s)
And to close out, you can make it so
[11:59] (719.28s)
there are many ants, each with their own
[12:01] (721.28s)
individual random rules. Since they can
[12:04] (724.40s)
use different colors, if an ant
[12:06] (726.16s)
encounters a color that is not
[12:07] (727.76s)
explicitly defined in its rule set, it
[12:10] (730.16s)
will treat it as color zero, black. Now,
[12:13] (733.28s)
I don't know about you, but this is
[12:14] (734.72s)
starting to look very biological to me,
[12:16] (736.88s)
like an ecosystem. I think there is an
[12:19] (739.28s)
evolution simulation waiting to be built
[12:21] (741.36s)
here. something like if an ant produces
[12:23] (743.76s)
enough of a certain color, it will
[12:25] (745.60s)
reproduce itself and mutate its
[12:27] (747.84s)
offspring's rules. I think that might be
[12:30] (750.16s)
too simple and probably lead to huge
[12:32] (752.64s)
overpopulation. So, there needs to be a
[12:34] (754.72s)
way of callulling their numbers. I'll
[12:36] (756.48s)
play around with it and maybe with AI
[12:38] (758.32s)
help, I can build something like that
[12:39] (759.76s)
within the century. But that's it for
[12:42] (762.40s)
now. If you make anything cool with this
[12:44] (764.24s)
simulation, please post it on my
[12:45] (765.68s)
Discord. And thanks to my patrons for
[12:47] (767.52s)
making this possible. I'll leave you
[12:48] (768.96s)
with some cool footage. Thanks for
[12:50] (770.48s)
watching and I'll see you later.
[12:56] (776.25s)
[Music]
[13:47] (827.66s)
[Music]
[13:56] (836.23s)
[Music]