Minutiae is an agent-based simulation framework written in Rust that operates on a finite 2D universe of cells and entities. All state and logic are type checked by the Rust compiler, making writing bug-free simulations easier. Minutiae is a personal project that I mainly created to serve as the basis for a variety of other personal projects. As such, it contains features that are largely custom and not general purpose, as well as being unstable.

Design + Architecture

Minutiae is an agent-based simulation framework, meaning that the active portions are entities. Entities reside at a single coordinate in the universe and behave according to logic provided by the programmer. In short, entities use information about the universe including the state of cells and other entities to create actions which are dispatched to the simulation engine. The engine queries all entities in the world for their actions and then applies them to the universe according to rules. This process proceeds each tick, after which middleware can be used to do things like render the simulation state to a visualization, perform manual updates to individual cells, or other things.

Code Sketches

One of the uses for which I've found Minutiae to be especially well fit is in creating small, self-contained code sketches. A perfect example of one of these is this fish sketch:

A Minutiae simulation of fish showing blue pixels (fish) and green pixels which they seek out and consume (food).

The fish (blue pixels) move randomly until a food particle (green pixel) comes within their view range, at which point they move towards it and consume it. The core of the fish entity logic can be found here.

In some cases including my noise function compositor, Minutiae is used simply as a convenient container for a 2D universe with built-in methods for rendering to GIF, HTML Canvas via WebAssembly, or even text to the terminal. Some standalone examples of this behavior can be seen here: https://ameo.link/noise/ and https://ameo.link/colors/.

Client/Server Support

In addition to creating simulations that run locally, Minutiae also has support for creating networked simulations that run remotely and can be connected to by multiple clients. There are three supported "modes" of server, each of which handles state synchronization in a different way.

Thin mode sends raw pixel data to clients, performing no simulation logic at all on the client side. This is the simplest to implement: just serialize the rendered universe into bytes, optionally compress them, send them over a WebSocket, and display them on the client. The downside is that for simulations that change rapidly, the network bandwidth is often infeasibly high. A potential solution is sending diffs rather than full images, but I've not yet implemented that.

The second is hybrid. In this mode, the client simulates the simulation locally but doesn't actually run the ticks independently. Instead, the client receives user-defined events from the server which it applies to the universe. Combined with sequence numbers and snapshotting, this allows an accurate version of the universe to be maintained by the client that matches the root truth of the server.

The last mode is fat. I have never actually fully implemented this mode, as it entails some complex synchronization logic and I haven't really had a need for it myself. The premise is that the full simulation is run locally by all users, independently from the server. It will model the behavior of game engines, where clients communicate updates to the server and the server aggregates them and responds to all clients with updates that the clients then integrate into their versions of the world.

Interactive Simulations

Minutiae is capable of supporting more complex and interactive simulations, such as