A browser game that teaches concurrency in JavaScript, played with an ant colony.
Your colony needs a map of every chamber in its nest. You have a handful of worker ants and one brain that they all share, which is exactly how JavaScript works: one thread runs your code, while any number of waits happen at once. Starting from nothing, the game builds up to the concurrent web crawler asked about in real interviews, and makes sure you know why every line of it is there.
Each chapter explains one idea, lets you poke at it until it clicks, then asks you to write a little code that the game tests for you.
Play online at https://sethatwood.github.io/concurrantcy/. Nothing to install or sign up for.
To run it from your own copy, open index.html in a browser: no install, no build, no server. If your browser won't run the code challenges from a file:// page, serve the folder instead with python3 -m http.server and visit http://localhost:8000.
Tested in Chrome. It uses only standard browser features, so other modern browsers should work too.
Progress and the code you write are saved in your browser. "Reset my progress" on the home page clears them.
Every chapter adds one piece. Chapter 9 puts them together, and chapter 10 carries them over to threads.
| # | Chapter | You play | You write |
|---|---|---|---|
| 1 | The colony's mission | Scout a small colony by hand | A breadth-first crawler |
| 2 | Waiting isn't thinking | A timeline of ants sharing one brain | Quiz |
| 3 | The brain's to-do list | Predict the output, step through the event loop | Prediction puzzles |
| 4 | Order slips | One-after-another vs. all-at-once | scoutAll with Promise.all |
| 5 | Two ants, one chamber | Cause a check-then-act race | A fix for a racing crawler |
| 6 | The storeroom key | Make stored food vanish | A Mutex built from promises |
| 7 | The job board | Watch ants go home too early | runPool, a worker pool |
| 8 | The nursery | Polling vs. sleeping vs. waking everyone | A condition variable |
| 9 | The great crawl | A replay of your own crawl | The concurrent crawler |
| 10 | Beyond one brain | Break JavaScript-safe code with threads | Quiz |
The glossary inside the game (linked from the home screen) defines every term, both in the game's words and in the words interviewers use.
Plain HTML, CSS and JavaScript loaded as classic <script> tags, so the game works straight from disk.
js/core.js: DOM helpers, storage, progress, syntax highlightingjs/graphs.js: the colonies (small test websites) used by demos and testsjs/farm.js: draws a colony and animates ants on itjs/widgets.js,js/scheduler.js,js/eventloop.js: quizzes, timelines, the replay, the scheduler puzzles and the event-loop stepperjs/runner.js: runs player code and tests in a Web Worker, so a stuck loop can be stopped without freezing the pagejs/challenge.js: the code editor and test resultsjs/chapters/: one file per chapter
MIT. Use it, fork it, teach with it.






