Swarm 0.6 release

Posted on July 14, 2024 by Brent Yorgey

The Swarm development team is pleased to announce the latest (alpha) release of the game.

It’s been quite a while since our last release, so this one includes a lot. Some of the biggest highlights include native Windows support, customizable keybindings, type synonyms and equirecursive types, many UI improvements, and a prototype tournament server where players can upload their solutions to challenge scenarios.

We also have a new Discord server—come say hi!

Read on for a more in-depth discussion of some of the new features, or see the CHANGELOG or even the complete list of git commits.

What is it?

As a reminder, Swarm is a 2D, open-world programming and resource gathering game with a strongly-typed, functional programming language and a unique upgrade system.

New challenge scenarios

There are a number of new challenge scenarios included in this release, with example screenshots shown below.

Language improvements

In terms of the Swarm programming language, this release has two big new features and one breaking change, adds several primitive commands, and fixes one embarrassing bug.

New primitive commands include volume (for measuring enclosed areas) and sow (for planting things that grow and spread). In addition, quite a few primitive commands that were previously only available to system robots or in creative mode now have corresponding craftable entities (e.g. selfdestruct via detonator; teleport via infinite improbability drive; push via dozer blade; etc.)

The big new features are type synonyms and (equi-)recursive types. For example, you can now define a type of lists like so:

tydef List a = rec l. Unit + a * l end

def length : List a -> Int = \xs.
  case xs
    (\_. 0)
    (\c. 1 + length (snd c))
end

Note that types must now start with uppercase letters, but you can use swarm format --v0.5 to convert old code to the new format.

Finally, an embarrassing bug where variable names sometimes shadowed things in outer scopes has been fixed via a massive rewrite that ended up closing a total of ten issues all at once.

UI enhancements

This release features a number of improvements to the user interface. For example:

Structure recognizer

Scenario authors can define “structures”—2D configurations of entities—that can be composed into larger scenes. New is the ability to recognize when the player has assembled one of these predefined structures, which can be used as a goal criteria or to trigger other events.

Structure recognition is implemented as an efficient 2D Aho-Corasick matcher. Modification of a cell in the world triggers a scan for matches against the library of defined structures. Metaphorically speaking, a “house” will be recognized exactly when the last “brick” is placed.

Cabal sublibraries

A potentially underappreciated feature of Cabal is the ability to split a package into self-contained internal libraries, known officially as “sublibraries”. This has been a powerful tool for us to clean up inter-module dependencies and establish system boundaries. Better disciplined dependencies between modules has sped up incremental compilation and makes it easier to navigate around the code.

We were also able to split off tool functionality that depends on heavyweight external packages (e.g. pandoc) without bogging down compilation of the main game.

Refactoring into sublibraries starts by selecting a group of modules that is ostensibly self-contained, then iterating with compiler feedback to find where our boundary assumptions are incorrect. This process yields more generic code with loose coupling and high cohesion.

Sometimes it’s just a matter of relocating code between modules or introducing a dedicated “Types” module. In certain cases, we learn that code destined for the sublibrary has references to a “downstream” type; that is, the type is defined in a library that depends on our new sublibrary. We can parameterize the sublibrary code on that type, and just pass it in concretely at the downstream call site. For example, we made the code dealing with world composition independent of the Entity type (#1836, #1924).

Give it a try!

To install, check out the installation instructions: you can download a binary release (for now, Linux only, but MacOS and Windows binaries should be on the horizon), or install from Hackage. Give it a try and send us your feedback, either via a GitHub issue or Discord!

Future plans & getting involved

We’re still hard at work on the game. Fun upcoming things include:

Of course, there are also tons of small things that need fixing and polishing too! If you’re interested in getting involved, check out our contribution guide, come join us on Discord, or take a look at the list of issues marked “low-hanging fruit”.

Brought to you by the Swarm development team:

With contributions from:

…not to mention many others who gave valuable suggestions and feedback. Want to see your name listed here in the next release? See how you can contribute!