Every good game needs a Battle Royale mode, right? Okay maybe that's something you'd be more likely to expect from an actual online multiplayer AAA title looking to jump on a bandwagon, rather than a traditional roguelike :P
Nonetheless, I did build one for Cogmind! It was going to be Cogmind's next April Fools Day event, with the idea originally sparked by a player's "what if"-style comment on Discord earlier this year.
If you're not familiar, "Battle Royale" is basically free-for-all survival of the fittest gameplay across a shrinking play area filled with random gear. So here you'd basically be up against a bunch of other Cogmind-like bots trying to survive. I'd never actually played any of the staple games in this genre, my first and only relevant experience coming during 7DRL reviewing for 2019, when I played B-Line, a take on the BR genre within a traditional roguelike framework (original video, when I was going back and playing the top 7DRLs for the year).
I say "was going to be" the next AFD event because although it reached a playable and somewhat fun state, I ended up cancelling it! I'll talk more about why later on, but first let's look at the development process and its challenges and solutions...
Like many ideas, as a pure concept "Cogmind: Battle Royale" sounded pretty interesting, but I wasn't sure just how feasible it would be on a technical level. I mean sure it's doable, but would the cost be worth it? A pair of very important questions needed to be answered first, so development started with an exploratory phase directed at answering them before actually building this as a special mode.
The first question had to do with factions. Cogmind's whole relationship system is based on a limited set of hard-coded factions, and there are only 10 of these internally. How to build a system to support free-for-all hostilities between numerous robots? The most straightforward solution would be to dynamically create a unique new "faction" for every single robot. What might this break? I had no idea, since lots and lots of assumptions had been made and reinforced since development began in... 2012 for 7DRL xD. I wasn't sure how flexible the faction system was, but this was a natural place to start since it would be much easier to test than question #2 to come. I simply created a bunch of extra factions and dropped a single Grunt in each, heading off the few problems that might result and sure enough, each one was running around shooting anything that moved and otherwise behaving as expected. Yay!
Grunts successfully wreaking havoc on -10/Materials, and each other.
The second question would unfortunately be much much harder to answer. It would take a while to explore the feasibility of an AI with Cogmind-like behavior, having the ability to put together and maintain a build from found and salvaged parts, and also manage inventory.
Now if I was just doing this purely for a short special event then I'd be less willing to venture into complex AI territory, essentially because it's an endless time sink (!), but I liked how this little detour could bring me one step closer to another project I've thought about off and on over the years: Having a bot that can actually play Cogmind.
So it was worth a shot and I spent some days hacking together an AI much more complex than anything else in Cogmind (robots normally have relatively simple and predictable behaviors unique to their class, where interesting scenarios are produced by interactions with numerous AIs at once rather than especially smart and capable individuals).
Abominations in that mode are capable of gathering parts to build themselves, but do so very haphazardly and take a lot of shortcuts, being capable of telekinetically attracting any parts they see and pretty much ignoring balance because they don't need to worry about energy or heat and always have a permanent form of natural propulsion and built-in backup weapon. For build management purposes, architecturally there's a pretty big difference between an AI allowed to both decide on and complete an action in a single moment, and one that makes a decision then follows it up over multiple turns in a changing environment.
In short, Abominations are a far cry from a true Cogmind-like inventory management AI. But they did require repurposing the player item autoswap feature for AI use, which would form an important backbone of the new AI. As small as it was, at least that bit was already done. To recap, back in Alpha 5c (2015) I added the ability to use a series of simple and predictable rules and to automatically perform obvious inventory management actions on request.
The original diagram I made to explain the smart/automated inventory management system
back when it was first added.
Nearly all the same logic could be used by AIs as well, so we have a pretty solid foundation to work from!
The new AI clearly still had a wider range of needs, though, so at this point I didn't actually start creating the new mode or a Battle Royale map, instead basic AI testing simply happened in a regular Cogmind map. In the first phase of development, I added the following features in this order--the AI could:
- use core hover (normally all robots other than the player are immobile if they have no external propulsion)
- switch to different faster forms of propulsion if more efficient
- collect parts to fill empty slots and also upgrade existing attached parts (however, because this is the AI rather than a player, it can take even more liberties with the swapping, for example removing inactive propulsion that doesn't match the current movement mode to make room for more of the active type)
- manage mass vs. support, for example avoiding adding so much mass it goes past a desired overweight threshold, and tries to shed heavier parts if it's suddenly gotten heavier due to build changes, to maintain speed
- wander the map while improving its build without fleeing under fire (since it needs to prioritize searching for and collecting weapons if it's been disarmed)
- seek out Matter and Protomatter
The first-ever AI to pick up its own parts, when I first started the project.
A slightly less stupid (but still very stupid) later version.
Here I also considered adding ramming to their basic abilities, so that like Cogmind the AI could also have a useful attack while disarmed, but found there were too many complications so although I figured out how it would be possible, ultimately decided it wouldn't be worth it for this event.
I didn't get into personalized behavior of any kind, like AIs with a preferred style, since there's already plenty of randomization and variety coming from the many many parts and their conditions at a given time. This would be a natural future step for a more involved project, however.
The complete non-combat portion of the AI can be summarized with pseudocode like so:
Cogmind Battle Royale AI pseudocode (non-combat state).
Once the Battle Royale AI reached this stage, it had started getting complex enough that it was really annoying trying to fine tune it while working in regular Cogmind/0b10 maps where there are too many distractions. About time to make the new map!
The idea behind this mode was that there'd be only one map, the first ever Cogmind mode to pare down the game into such a small "world." Initial plans set it at 200x200, the same size as Factory/Research, based on my experience designing maps of that size relative to movement speeds, the ranges of sensors and weapons, and perhaps most importantly the total number of participants. 30 seemed like a good number.
At first it was going to be like a typical Cogmind room-and-corridors style map, with a final central room on which the last living bots would naturally converge as the accessible area shrank. Here I was just starting out getting the map generator building out from the central room:
As I was fooling around with trying to get it to do what I wanted, a different better idea popped into my head: What if instead of using the normal subterranean-style maps we instead directly converted it to a sort of overland map where rooms are instead "structures"?
This would significantly open up the map, creating additional pathways and a sort of "organized chaos" in the form of a little town without clear straight roads, but all locations are still accessible.
I like it! Some of the strategy implications of this approach:
- makes it much easier to navigate and reach the center (if necessary one can technically even just blow through walls to reach the center once you have orientation)
- makes it easier to escape if you're faster than a pursuer, harder if you're slower (and harder to give chase if you're slower)
- easier to spot enemies and be spotted because generally more open
- less likely to get unnecessarily trapped by the closing circle of death
Plus it's also kinda neat just to have a different kind of map to play around with.
I called the map "Wartown."
Mechanics and Features
We've got a basic AI and a basic map, next up are features!
- Everyone spawns in their own room, usually out near the edges of the map.
- Everyone starts with the same base stats and slot count, but completely randomized gear. It's more interesting to be forced to adapt, but rather than having players gradually collect their parts from around the map, that entire process can be sped up by simply starting with it. This is more appropriate for Cogmind anyway, because one or two parts alone isn't enough for an interesting or fun build--you really need a larger collection to be at all effective or to more quickly convert into something effective.
- Random parts are also scattered across the map (some items found in the regular game are excluded, however, generally things that wouldn't make sense in this mode).
- There is no Matter cost associated with attaching parts. This rule change was partially put in place to make inventory management a little easier on the AI (no need to consider Matter waste alongside repeated build tweaking), and also to speed up gameplay in general because it would otherwise be easier for players to run low on or out of matter.
- Attacks enforce RPGLIKE-like damage redirection where some part damage is transferred to the core, but in this case the rate is only 50% (and armor transfers only 25%). I wanted parts to still take plenty of damage and be destroyed, but at the same time didn't want too much damage focused on target cores because otherwise bots wouldn't last long enough in a confrontation, at least not long enough to allow for some tactical variety.
- Cogmind's parts do not have their usual high-integrity critical strike protection, and no bot can have their core automatically destroyed by a critical strike.
- All bots use the normal player-Cogmind rules for increasing system corruption when his with EM damage (so it's no longer as much of a threat to other robots as it normally is).
- In addition to salvageable parts, destroyed bots drop both Matter and Protomatter, the latter of which does not decay and is applied in full each turn where necessary/available just by standing on it. Borrowing Protomatter from RPGLIKE mode was essential in maintaining balance because without a way to repair, attrition would inevitably lead to death after one or more confrontations.
- On destroying a target, the attacker gains a new random slot (awarded on the following turn). This allows for a form of progression, ensuring it's less advantageous to simply hide from everything and pop out at the end to kill the last remaining enemy, since whoever they are they're quite possibly more powerful by then.
- Ambient heat slowly spreads from the four corners of the map towards the center. This is the so-called "circle of death" mechanic important to Battle Royale games in order to force players into eventual contact with one another while keeping it from getting boring. I like the idea of using heat rather than damage to achieve this goal because it builds gradually as it approaches and builds with good dissipation can afford to stay near or in the hot area for longer, not to mention heat has different kinds of side effects. In the end no build can withstand the full intensity of the heat, of course, it just allows for more or less flexibility in that area. The AI is aware of the heat area and acts accordingly.
- Once only a single bot remains, an exit appears in the center of the map.
The heat's color effect is achieved via additive RGB based on the actual ambient heat per cell, so maximum heat actually appears yellow (although the animation still plays out for all hot locations so it's not a constant yellow).
Each player is also assigned a random name with their player number attached. For this I wrote up a list of hundreds of Cogmind-relevant words for use in compounds.
Sample generated Battle Royale "player names."
Normally I would've cancelled an idea a lot sooner in development than this (like the real-time arcade version of Cogmind I never even wrote about here but released to patrons at one point :P) but due to the investment required to develop the necessary AI, it took a while to reach an MVP state so I didn't get to testing whether it was actually a good idea for a while xD
As soon as it was semi-playable I immediately realized it wasn't quite going to work, at least not without a huge amount of additional investment that just wouldn't be worth it for a special mode.
In the end, Cogmind's mechanics and gameplay weren't designed to be all that compatible with 1v1 fights between equals, which is what Battle Royale tends to boil down to--you have a bunch of essentially identical players all vying for the win, but Cogmind is meant to be a more tactical one vs. many game (or many vs. many, with factions) in which most bots die quickly and the situation keeps changing as a result, rather than just sitting in one position pelting enemies, which is often what BR mode using Cogmind mechanics ends up as. Certainly you can do a fair amount of stationary farming in regular Cogmind, too, but there's still a lot of thinking that goes into the plan before the fighting even starts, and that determines how the fight will be likely to go--this is something the AI can't really do on an equal footing with the player, and it ends up being less interesting as a result.
In BR mode, AIs spot a target and then sit there doing their best to pummel it to death if they're capable of attacking. Without a much smarter tactical AI that can come up with environment-related tactics and exercise more forethought and better react to spacial disadvantages, it just doesn't work well.
In hindsight this all should've been obvious or could be realized via thought experiment alone, but I was clearly hyperfocused on the AI development aspect and really wanted to give it a try anyway :P
Before stopping work on BR mode, however, I actually put some more hours into it so that it'd be a more complete and fully playable prototype for patrons who'd like to try it out, and feedback was actually decent! (maybe I was too harsh on the mode and should bring it back one day with a bit more development? :P) The heat mechanic, among some others, is an example of a feature that wasn't even implemented yet when I first decided to cancel--I admit I also really wanted to see what it might look like :D
I released a special Battle Royale build on Patreon here, and since then have updated the build several more times (in place on the original page) to address bugs and further improve the AI.
A rather quick and explosive skirmish in BR mode.
Features missing from this mode, as released, but that I would have addressed later:
- prefabs (including special stockpiles and especially better treatment for the center area)
- more attention to machines (all I did was throw some random machines into the mapgen pool, where ideally the types and compositions would be selected for both better gameplay and atmosphere)
- message log details about who is destroying who
- Haulers that teleport in and carry lots of great gear, and everyone gets a ping of their locations (works as a mechanic to force confrontations and give extra rewards those who succeed)
- different enemy colors to reflect their state
- different game over screen, a leaderboard ranking all the "players" (unique scoring system) and showing their build classes
- even better AI :P
- a more balanced experience overall, or at least "balanced" to maximize FUN
Fortunately most of the work that went into this mode didn't go to waste. Cogmind Battle Royale may have been cancelled, but the AI lives on! I've continued to improve on it (vastly!) for use in a different special event, and there is at least one part of the regular game where I'm interested in incorporating just such an AI. So I'd consider this project a success overall.
This side project also resulted in some general AI improvements and even discovering and fixing one relatively new AI behavior bug that hadn't yet been reported.
I'm not sure whether I'll ever get to that AI can reasonably play the game, although the next little step towards that goal is only barely beyond what we have now--just take the first exit spotted ;)