Project Langtoncraft: When Langton's Ant Meets Starcraft [WIP]

Num7

Administrator
Staff
Messages
12,457
Hey everyone,

Have you heard of Langton's ant before?

It's a cellular automaton. A pixel-thing that moves on a pixel grid inside a simulation.

Its moving pattern is as follows:
  • At a white square, turn 90° clockwise, flip the color of the square, move forward one unit
  • At a black square, turn 90° counter-clockwise, flip the color of the square, move forward one unit
Basically, it moves according to what color a pixel is. Then it switches this pixel's color. Repeat.

Here's an animated version from Wikipedia:
LangtonsAntAnimated.gif


After about 11,000 steps (movements), out of the chaos, appears a pattern, a highway:

1703877718925.png

About 6-7 years ago, I created a Python version with a friend. It simulated a Langton's ant, in a classic, infinite mode. Here's an example in which you can see the highway crossing-over from one side to the other.

1703877803339.png

It also had a free-for-all mode, in which many ants were "fighting" and interacting with one another:

1703877884729.png

So, the other day, I was watching Marbles on Stream on Twitch, and I was thinking to myself, how clever it was. Marbles on Stream is a random game of marbles rolling down paths and obstacles. Nothing special there. What's special is that when you're watching a stream, you can type !play in the chat and join the game. From the Twitch chat!

So I was wondering, what kind of game or simulation could I possibly create that could integrate with the Twitch chat in such a fashion. I kept thinking about it for a little while, until, suddenly, I thought of this Langton's Ant simulator we created years ago. What if I stream it and have people from the chat join and have their own ant? That sounded cool.

So I went ahead and started modifying the code. I was able to easily integrate the thing with Twitch. It works pretty good. But the free-for-all you see above, this colorful mess, is pretty boring. It takes place in a blank space. So I decided to have it take place on a map instead. Now, what kind of map could I use? Am I supposed to create one?

I happened to randomly watch a dude stream Starcraft Brood War on Twitch. Then I thought... Why not have the Langton's ants fight on a Starcraft map? Why not "The Hunters"? The absolute classic. So I went ahead and implemented this map with collision detection that would prevent ants from moving over certain types of terrain (water in this case) and such.

Then it seemed only logical to add resources. Minerals and Vespene gas. At that point, I decided it was going to become a Starcraft-themed simulation.

Here is what it looks like right now:

1703878385546.png

When the ant moves close to mineral and Vespene geysers, it gathers some. The minerals are used to upgrade LVL, which allows your ant to move faster. Vespene gas doesn't have any use yet. Suggestions welcome. Perhaps a !boost chat command that would consume Vespene gas in exchange for a bonus? We'll see.

The players in this screenshot are all fictional. But earlier today I booted it on Twitch and @TimeWizardCosmo joined the simulation. It worked great.

It's a pretty fun project, I gotta say I have a lot of fun coding it and having it evolve over its iterations. I haven't programmed like this in years and it feels awesome.

To be continued! :)
 
Last edited:

TimeWizardCosmo

Senior Member
Zenith
Messages
2,936
Such a cool idea, it's been fun watching you put it together :)

I don't know how it would work, but since the player count is finite, it would be cool if spectators could bet on a winner using channel points. Or maybe have a "team", so joining an existing color or something bolsters it's speed/power or whatever. There's a lot of directions this could go, and you've got the iterative mindset to make this the next AI Santa. Great work man.
 


Top