Show HN: Swarm – Program a colony of 200 ants using a custom assembly language
183 points by armandhammer10 24 hours ago | 61 comments
We built an ant colony simulation as an internal hiring challenge at Moment and decided to open it up publicly.

You write a program in a custom assembly-like (we call it ant-ssembly) instruction set that controls 200 ants. Each ant can sense nearby cells (food, pheromones, home, other ants) but has no global view. The only coordination mechanism is pheromone trails, which ants can emit and sense them, but that's it. Your program runs identically on every ant.

The goal is to collect the highest percentage of food across a set of maps. Different map layouts (clustered food, scattered, obstacles) reward very different strategies. The leaderboard is live.

Grand prize is a trip to Maui for two paid for by Moment. Challenge closes March 12.

Curious what strategies people discover. We've seen some surprisingly clever emergent behavior internally.


TheAceOfHearts 18 hours ago
That's really cute, it reminds me that Will Wright (creator of The Sims) has referenced this book "The Ants", by Bert Holldobler in multiple occasions as a key inspiration for his games (and in particular SimAnt) and systems thinking. Did you come across that during your research phase or had you not heard about it? I haven't read it yet, but maybe someday I'll get around to it.
reply
lightamulet 12 hours ago
Hey, I'm the one who built this particular challenge!

I had no clue, but thanks for the book lead! It didn't come up directly, but SimCity 2000 and especially SimCity 4 had a huge impact on me growing up / I still spin up SimCity 4 from time to time, so I imagine there's a massive indirect influence haha.

reply
antfarm 10 hours ago
This is exceptionally beautiful. What did you use to build it? Vanilla JS?
reply
lightamulet 7 hours ago
This is actually all built in nextjs/react, though the initial sketches of the sim had no visualization and were just running in my terminal using bunjs
reply
sitkack 9 hours ago
Will Wright gave at least one great lecture at SIGGRAPH. Wonderful thinker and communicator. #ACM plz unlock this culture.

Ants have fascinated me from a young age, I’d construct a viewing platform so I could watch the hive at work.

My favorite were the carpenter ants, so smart. It feels like they have a theory of mind. I didn’t hurt them, but if you disturbe their nest under a board, the efficiency and expediency they would exhibit while collecting their young was fascinating.

*edit, I meant to ask if you had any other book recommendations?

reply
TheAceOfHearts 3 hours ago
Well, I'm currently reading through "Designing Virtual Worlds" by Richard Bartle. He's known for being one of the creators of MUD (multi-user dungeon). I'm not far along enough to make a judgement on the quality of the contents, but I keep seeing the book title pop up everywhere so it seems important.
reply
JamesTRexx 8 hours ago
Speaking of SimAnt, I soon discovered the bug that by moving into the top corner, the black ants would conquer all squares with no intervention from that one sideways and downwards and too easily win the game.

Still, it was fun just messing around with the ants, watching the trails, and chasing spiders by calling forth all ants.

reply
huflungdung 16 hours ago
[dead]
reply
ynac 10 hours ago
My "hello world" for a new stack is always a version of Worm. Somewhere between Life and your Swarm, Worm wanders around looking for food and water, trying to avoid birds and other issues. Each round the worm survives it grows by a segment. If it doesn't get food or water, it is reduced a segment. And so on. Your Swarm is a few levels up from my iterations, totally inspirational! Thanks!
reply
WillMorr 10 hours ago
I've been working on a surprisingly similar project for the last week: plants grow cells on a grid by executing a raw chunk of memory according to a simple instruction set. I'm aiming more for an evolution simulator, where each plant gets a 1kb brain that is randomized a little when a new plant is spawned.

Most plants right now settle into a simple goto loop that places the requisite cells to survive and then spam seeds until they die. I have seen some interesting variety in body plans emerge where plants sort into discrete species regionally. I'm hoping to eventually get decision making to emerge organically. If things go well this system is theoretically capable of sexual selection (and maybe fisherian runaway) but that's a pipe dream right now.

https://github.com/Will-Morr/PlantBrainGrid

reply
jlarks32 9 hours ago
The disclosure route is cut off at the bottom: https://dev.moment.com/disclosures

I cannot scroll to the Governing Law section

reply
i_am_a_squirrel 23 hours ago
what is this? assembly for ants?
reply
forkerenok 17 hours ago
It's assembly for people who can code good.. and can do other things good too.
reply
yesthisiswes 16 hours ago
It needs to be at least three times this size!
reply
RandomTeaParty 12 hours ago
just be glad that ants are ambiturners
reply
armandhammer10 23 hours ago
ant-ssembly to be precise
reply
testfrequency 20 hours ago
So hot right now
reply
JetSetIlly 16 hours ago
Cool. This is how I imagine the ants were programmed by the spiders in Children of Time.
reply
dastapov 7 hours ago
This sounds a lot like a task of 2004 ICFPC Programming contest: ants, pheromone trails, only local vision, etc: https://web.archive.org/web/20060709155354/http://www.cis.up...

I can't see the rules of this challenge, but it sounds really darn close.

reply
RandomTeaParty 17 hours ago
Did website break?

I only see "MOMENT" and "All systems nominal"

reply
greenbit 15 hours ago
Incredible low contrast font color in use there. Looks like about 0x002000 on pure black (per Mk-1 eyeball).

What possesses people to go for these barely perceptible color schemes?

.. a few minutes later ..

Ok, the crazy low contrast was on the initial landing page. Things have somewhat improved after prodding somewhat blindly at it.

I'll let the question stand though, bc why do that for what's going to be people's first impression?

reply
armandhammer10 15 hours ago
try pressing any key or clicking around :)
reply
Vibeguy900 8 hours ago
Make sure you lets those agents relax and recharge at https://vibesprings.net
reply
nozzlegear 20 hours ago
I think I read a Daniel Suarez book about this once.
reply
kleiba 20 hours ago
I wish I could read dark-mode but my eyes somehow cannot handle it (not just on that website, in general).
reply
purplehat_ 19 hours ago
there is a `theme set` command
reply
phreeza 17 hours ago
Reminds me of my personal HN glory days, now 16 years ago!! https://news.ycombinator.com/item?id=1395726
reply
ngvrnd 9 hours ago
Is it possible to reset the source once you've started modifying it?
reply
anta40 13 hours ago
So.... a sort of modern Corewar?
reply
general_reveal 16 hours ago
Orwell would suggest you use the word normal.
reply
orsorna 13 hours ago
The amount of effort put into this tool...just for hiring to your exact shop? I cannot imagine that's a good return on investment?
reply
lightamulet 12 hours ago
i think this took me (1 person) like 40 hours max? all built in the last week, though i spent more time than i should have on it haha. quite ai-assisted, that's how most of the layout like the editor, player controls, even eval server got set up.

i spent way too much time on things like the language itself, map generation, and figuring how to only recompute the sim on material code changes vs whitespace and comments (it assembles to "bytecode" with debouncing! and the sim component takes the bytecode as a prop).

we'll see if good ROI, we definitely intend to run more of these types of challenges in the future, so much of this work won't go to waste

reply
sixo 11 hours ago
There's also a trip to Hawaii in it for you.
reply
Kinrany 12 hours ago
People like doing cool stuff
reply
Thanakorn_551 16 hours ago
This is really quite cool.
reply
4b11b4 23 hours ago
Wait what this is the best reason to write a bunch of assembly AND learn about ants?
reply
armandhammer10 23 hours ago
And (potentially) go to Hawaii!

But in all seriousness, ants are smarter than they look. They operate as a collective. Just in the same way that assembly needs to operate collectively to get the best output.

They're more closely linked than they appear from the outside ;)

reply
dspillett 17 hours ago
> ants are smarter than they look.

Many moons ago I had a big pot of rhubarb in my back yard¹ and was initially irritated by the appearance of ants and aphids, until I took a moment to watch them and realise that the ants were bringing in the aphids and tending to them. The buggers were farming. The ants can't digest the leaves of the rhubarb, but the aphids can and excrete a sugary by-product that the ants “milk” from them. It is a fascinating bit of nature to read into. They even defend the aphids from predators and so forth, so it isn't a bad life for them either.

--------

[1] Not a euphemism for a lovely garden in that case, it was literally about a square yard of concrete behind the mid-terrace I was renting.

reply
embedding-shape 18 hours ago
> But in all seriousness, ants are smarter than they look.

I'd argue the opposite, ants are dumber than they look. You look at a random ant stack in the forest and it looks like they're smart, but that's only when they're "controlled" by the collective, individual ants themselves are pretty dumb in the end, but it's hard to see as typically we always see them around/in their stacks in nature.

reply
lukan 19 hours ago
As a collective, yes. If you look at individuals, they often go in circles and act really dumb. But for the colony it still works out, bigger brains would cost too much energy I suppose and simple algorithms work. (I often watched real ants while and my head translated their behavior to simple algorithms)
reply
kitd 19 hours ago
Someone else who has read Godel, Escher, Bach by Hofstadter?
reply
oddmade 19 hours ago
Excellent book cheers
reply
macleginn 13 hours ago
What's with "artesenal"? Is this a joke that I don't understand or a surprising way to write "artisanal"?
reply
lightamulet 12 hours ago
the answer is my editor doesn't have spellcheck and i apparently don't know english as well as i thought, fixing :')
reply
ivanjermakov 14 hours ago
All dark themes are too low contrast. Give me pure white (including comments) on pure black please.
reply
lightamulet 12 hours ago
on the home page (dev.moment.com) you can type `theme -h` and then `theme set [name]` to change the color scheme, which carries forward to the sim!
reply
ivanjermakov 12 hours ago
Yes. I checked every theme and all dark themes are too low contrast. Pacman is good but comments are barely readable (gray on dark gray).
reply
nurettin 23 hours ago
This is a balancing act between collectors and explorers. There is probably some optimized number. Likely targeted at beginners.
reply
FpUser 17 hours ago
Am I being dumb? I was expecting to see ability to look at and run some canned sim
reply
TruffleLabs 24 hours ago
Why? =>

"Moment Engineering by Moment Technology wants to access your {GitHub account name} account Personal user data Email addresses (read-only), profile information (read-only) This application will be able to read your private email addresses and read your private profile information."

reply
sudo_cowsay 24 hours ago
Nice way of hiring but is it really worth it to give the public a trip to Maui (kinda expensive these days)

Does it really reveal that much talent to make it worth the money?

Just curious

reply
tgsovlerkhgsel 14 hours ago
The prizes (Maui trip, second/third prizes, swag kits, shipping for the swag kits) probably cost around $20k in total.

Assuming an engineer costs $200k/year, 200 effective working days per year, that's 1k/day. Developing the contest (from the idea to building the rules to building the site to playtesting) likely cost more than 20 eng-days, making it the biggest cost.

Hiring is expensive. If it takes 30 minutes to screen one candidate for suitability for the "real" interview and 5h to do a "real" interview (including evaluation etc.), 5 screenings for one interview-worthy candidate and 5 interviews for one hire (I suspect the real factors might be closer to 10), that's 12.5h of screening and 25h of interviewing per hire.

reply
boutell 12 hours ago
Sure, hiring is expensive, but firing is really expensive! I salute your efforts to get it right on the first try.
reply
armandhammer10 24 hours ago
It's less about the money. It's about giving people a chance to do something fun / show off their skills and get rewarded for it.

Plus, Hawaii is awesome.

reply
dr_kiszonka 23 hours ago
I think it is a fun contest! As for recruitment, it suggests to me you are looking for people with no kids, and possibly young people.
reply
nylonstrung 18 hours ago
Appreciate this, very cool of you to do that
reply
AndrewKemendo 13 hours ago
Way less than you would pay for a recruiter

they usually ask for a non trivial percentage of the first year salary

reply
jackfranklyn 19 hours ago
[dead]
reply
devcraft_ai 20 hours ago
[dead]
reply
lambchop_395 12 hours ago
[dead]
reply
mdk017 13 hours ago
[dead]
reply
Uptrenda 20 hours ago
[flagged]
reply
mock-possum 20 hours ago
> my goy master

I’m sorry your what now?

reply
Uptrenda 20 hours ago
sorry, im jewish, lets not be racist here
reply
wizzwizz4 16 hours ago
Nobody who talks like this has ever been Jewish, in my experience: you'd be the first.
reply