In Captain Forever Remix, you hand-craft a killer spaceship from various types of modules—lasers, missile launchers, twin boosters, shield modules, you name it. Enemy ships, however, are generated procedurally. Here’s a summary of the simple but effective process that creates enemy ships.
The goal of this system is to populate the game world with a diverse array of enemies. Ideally, the nuances of combat will differ from encounter to encounter, such that you’ll feel compelled to assess any given enemy’s threat based on its module composition, and switch your tactics accordingly.
Our system is intended to handle a variety of ship types—basically, unique “blueprints” for ship-building. To keep things simple, let’s walk through the construction rules for the most common ship type, the “mirrored” ship (named so because its pieces are always mirrored across its vertical axis).
Step 1: Start with the command module.
Step 2: Add bulkheads to form the ship’s skeleton.
Bulkhead modules are attached at various randomly-determined positions, from the command module outwards). These pieces are mirrored across the vertical axis of the ship. The number of bulkheads we add is randomly picked (from within a range), such that ships vary in their overall size and shape.
Step 3: Add the standard laser/booster.
So that every enemy has basic movement and combat abilities, we always attach a laser to the very front-middle of the ship, and a booster to the very back-middle.
Step 4: Decorate the wingspan with weapons and boosters.
From the pool of all possible module types, we select a small subset that will be used to build the ship. We make selections via weighted random choice, allowing us to control the relative rarities of the various module types.
At present, we’ve tuned things such that each ship will feature a relatively low number of module types, which tends to specialize a ship’s function. This, in turn, requires the player to counter its particular threat with specific tactics.
We attach the chosen types of weapons and boosters along the wingspan (the horizontal axis of the ship). We move along one wing, then mirror the results on the other wing. These modules always face up or down, depending on whether they are “above” or “below” the wingspan. This process is random, but constrained by quotas (for example, we might mandate that at least 30% of modules along the wingspan are boosters).
Step 5: Add “wing caps.”
As a finishing touch, we attach a pair of horizontally-facing (left/right-facing) modules on the “wingtips”—the extreme left and right sides of the ship.
And that’s our basic process for ship-building. Fairly straightforward stuff, but powerful—all the ships seen here are created by this process!
(A note on how this approach came about. Captain Forever Remix is based on the original Captain Forever by Farbs, so the majority of the ideas presented here originated in Farbs’ code. We’ve tweaked a few things to suit the Remix’s purposes, and we’ll continue to experiment throughout development.)