Skip to content

Commit

Permalink
0.6 release (#6)
Browse files Browse the repository at this point in the history
Blog post and documentation updates for the 0.6 release.
  • Loading branch information
byorgey authored Jul 15, 2024
1 parent ca0ca4a commit e254355
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 1 deletion.
193 changes: 193 additions & 0 deletions blog/2024-07-14-swarm-0.6-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
---
title: "Swarm 0.6 release"
author: "Brent Yorgey"
---

The [Swarm](https://github.com/swarm-game/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][discord]---come say hi!

Read on for a more in-depth discussion of some of the new features, or
see the [CHANGELOG](https://github.com/swarm-game/swarm/blob/main/CHANGELOG.md) or even the [complete list of git
commits](https://github.com/swarm-game/swarm/commits/main/?since=2023-11-01&until=2024-06-23).

## 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.

![](../gallery/beekeeping.png)

![](../gallery/fishing.png)

![](../gallery/dimsum.png)

## 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](https://github.com/swarm-game/swarm/pull/1583), 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](https://github.com/swarm-game/swarm/issues/681) has been fixed
via a [massive rewrite that ended up closing a total of *ten*
issues all at once](https://github.com/swarm-game/swarm/pull/1928).

## UI enhancements

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

- Typing an open bracket at the REPL now automatically inserts a
matching close bracket ([#1953](https://github.com/swarm-game/swarm/pull/1953))
- Rather than highlight the entire REPL input in red when there is an
error, now only the specific portion indicated as the source of the
error is highlighted ([#1957](https://github.com/swarm-game/swarm/pull/1957))
- Popup notifications for new achievements, recipes, and commands ([#2027](https://github.com/swarm-game/swarm/pull/2027))
- Customizable keybindings ([#1979](https://github.com/swarm-game/swarm/pull/1979))

## 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.

![](../gallery/structure-recognition.png)

Structure recognition is implemented as an efficient 2D [Aho-Corasick](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm) 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](https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html#library)".
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.

<div style="text-align:center;">
<img src="../images/sublibrary-graph.svg" width="250">
</div>

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](https://github.com/swarm-game/swarm/pull/1836), [#1924](https://github.com/swarm-game/swarm/pull/1924)).

## Give it a try!

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

[install]: https://github.com/swarm-game/swarm#installing
[release]: https://github.com/swarm-game/swarm/releases
[hackage]: https://hackage.haskell.org/package/swarm
[issue]: https://github.com/swarm-game/swarm/issues/new/choose

## Future plans & getting involved

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

- More fully fleshed-out [tournament server](https://github.com/swarm-game/swarm/pull/1798)
- [Saving and loading games][saving]
- New world features like aliens and [cities][cities]
- New language features like [arrays][arrays], [inter-robot communication][robot-comm], and [a
proper `import` construct][import]

[cities]: https://github.com/swarm-game/swarm/issues/1944
[saving]: https://github.com/swarm-game/swarm/issues/50
[arrays]: https://github.com/swarm-game/swarm/issues/98
[robot-comm]: https://github.com/swarm-game/swarm/issues/94
[import]: https://github.com/swarm-game/swarm/issues/495

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

[contrib]: https://github.com/swarm-game/swarm/blob/main/CONTRIBUTING.md
[low-hanging]: https://github.com/swarm-game/swarm/issues?q=is%3Aissue+is%3Aopen+label%3A%22C-Low+Hanging+Fruit%22
[discord]: https://discord.gg/kp8MuSgkPw

Brought to you by the Swarm development team:

- Brent Yorgey
- Karl Ostmo
- Nitin Prakash
- Noah Yorgey
- Ondřej Šebek

With contributions from:

- Alexander Block
- Brian Wignall
- Chris Casinghino
- Chris Hackett
- Daniel Díaz Carrete
- Gagan Chandan
- Huw Campbell
- Ishan Bhanuka
- Jacob
- Jens Petersen
- Joshua Price
- lsmor
- Luis Morillo
- Mark Goadrich
- Norbert Dzikowski
- Paul Brauner
- persik
- Ryan Yates
- Sam Tay
- Steven Garcia
- Tamas Zsar
- Tristan de Cacqueray
- Valentin Golev
- Yaroslav Kozhevnikov

...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!][contrib]
Binary file added gallery/beekeeping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/beekeeping.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Beekeeping challenge scenario
Binary file added gallery/dimsum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/dimsum.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Dim sum restaurant challenge scenario
Binary file added gallery/fishing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/fishing.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Fishing challenge scenario
Binary file removed gallery/log.png
Binary file not shown.
1 change: 0 additions & 1 deletion gallery/log.png.metadata

This file was deleted.

Binary file added gallery/structure-recognition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/structure-recognition.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Recognizing user-built structures
127 changes: 127 additions & 0 deletions images/sublibrary-graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e254355

Please sign in to comment.