Wilden Dawn

Follow random organism

By Robin Dowling ยท 2 months ago

Following organisms by clicking them works well once you're looking at the simulation, but it requires finding an organism to click first. On a large world with organisms scattered across thousands of positions, this can take time. They can also be hard to catch sometimes. I wanted a faster way to jump into observation, to start following an interesting organism immediately without searching.

I added a "follow random" feature. When you're not currently following anything, the "following" label becomes clickable. Click it and you're instantly following a randomly selected motile organism, wherever it happens to be in the world.

The server implements this using reservoir sampling, an algorithm that selects a uniformly random element from a collection in one pass, using constant memory regardless of population size. The simulation maintains a cached random motile organism, updated each iteration, so responding to a follow random request is instantaneous.

When the server receives the follow random message, it retrieves the cached random organism and establishes a follow relationship, just as if you had clicked on that specific organism. Your viewport immediately centers on it. If the organism dies, the standard cleanup behavior applies and you stop following.

The implementation handles two distinct cases: following a specific organism you clicked, versus requesting any random organism. When you click the label, the client sends a "follow random" message. The server picks a random organism and establishes the same follow relationship as if you had directly clicked that organism. Both interaction types flow through the same code paths, with type safety ensuring consistent handling throughout.

The feature improves exploration significantly, especially for new visitors. Instead of navigating through the world looking for something interesting to follow, you can immediately jump into tracking an organism's life: see where it goes, what it does, how it interacts with others. If it's not interesting, stop following and request another random organism.

It's a small usability enhancement, but it removes friction from the primary way people explore the simulation, by following individuals and observing their behavior over time.